Android: What does this warning message refer to? - (WebCore)

AjOnFire picture AjOnFire · Apr 7, 2011 · Viewed 8.5k times · Source

I have a Gallery which contains WebView's as its children, when I scroll the Gallery I am getting the following warning,

'04-07 19:35:37.409: WARN/webcore(664): Can't get the viewWidth after the first layout
 04-07 19:35:37.470: WARN/webcore(664): skip viewSizeChanged as w is 0'

What does this warning refer to ? [I have not hardcoded any of the Layout params.]

Any light on why this warning occurs would be really helpful...

and these were printed too

04-15 11:10:13.202: DEBUG/webviewglue(617): nativeDestroy view: 0x257f40
04-15 11:10:13.243: DEBUG/webviewglue(617): nativeDestroy view: 0x25d680
04-15 11:10:13.292: DEBUG/webviewglue(617): nativeDestroy view: 0x240688
04-15 11:10:13.332: DEBUG/webviewglue(617): nativeDestroy view: 0x249918
04-15 11:10:13.373: DEBUG/webviewglue(617): nativeDestroy view: 0x226608
04-15 11:10:13.423: DEBUG/webviewglue(617): nativeDestroy view: 0x21e418
04-15 11:10:13.482: DEBUG/webviewglue(617): nativeDestroy view: 0x23a4e8
04-15 11:10:13.533: DEBUG/webviewglue(617): nativeDestroy view: 0x235c68
04-15 11:10:13.572: DEBUG/webviewglue(617): nativeDestroy view: 0x212a28

Thanks in advance.

Answer

While-E picture While-E · Jul 4, 2011

Your viewSize has changed and is notifying of this, with the width value of 0 for some reason (zoom possibly). As seen here:

// notify webkit that our virtual view size changed size (after inv-zoom)
            private void viewSizeChanged(int w, int h, int textwrapWidth,
                    float scale, int anchorX, int anchorY, boolean ignoreHeight) {
                if (DebugFlags.WEB_VIEW_CORE) {
                    Log.v(LOGTAG, "viewSizeChanged w=" + w + "; h=" + h
                            + "; textwrapWidth=" + textwrapWidth + "; scale="
                            + scale);
                }
                if (w == 0) {
                    Log.w(LOGTAG, "skip viewSizeChanged as w is 0");
                    return;
                }
                int width = w;
                if (mSettings.getUseWideViewPort()) {
                    if (mViewportWidth == -1) {
                        if (mSettings.getLayoutAlgorithm() == WebSettings.LayoutAlgorithm.NORMAL) {
                            width = WebView.DEFAULT_VIEWPORT_WIDTH;
                        } else {
                            /*
                             * if a page's minimum preferred width is wider than the
                             * given "w", use it instead to get better layout result. If
                             * we start a page with MAX_ZOOM_WIDTH, "w" will be always
                             * wider. If we start a page with screen width, due to the
                             * delay between {@link #didFirstLayout} and
                             * {@link #viewSizeChanged},
                             * {@link #nativeGetContentMinPrefWidth} will return a more
                             * accurate value than initial 0 to result a better layout.
                             * In the worse case, the native width will be adjusted when
                             * next zoom or screen orientation change happens.
                             */
                            width = Math.min(WebView.sMaxViewportWidth, Math
                                    .max(w, Math.max(
                                            WebView.DEFAULT_VIEWPORT_WIDTH,
                                            nativeGetContentMinPrefWidth())));
                        }
                    } else if (mViewportWidth > 0) {
                        width = Math.max(w, mViewportWidth);
                    } else {
                        width = textwrapWidth;
                    }

            }

The documentation I used for this reference is here for more information. Without seeing your code I'm not sure exactly why it's happening though. Then it is obviously just skipping the adjustment of any views with these parameters and thus you have your logs.

[EDIT] Without being able to show code (understandable) the only thing I can really reference other than what I said before is a discussion I read a while ago here, that sheds light on the fact that different contexts contain different data. You might be able to use the Activity Context instead of the Engine, or Application Context.. Not much help, but might be a first golden brick. :-? Good luck mate, hope you manage and I'll keep my eyes out for any references to give you.