简体   繁体   English

Android:此警告消息引用了什么? - (WebCore)

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

I have a Gallery which contains WebView's as its children, when I scroll the Gallery I am getting the following warning, 我有一个包含WebView作为其子项的Gallery,当我滚动Gallery时,我收到以下警告,

'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. 提前致谢。

Your viewSize has changed and is notifying of this, with the width value of 0 for some reason (zoom possibly). 您的viewSize已更改并正在通知此情况,由于某种原因宽度值为0(可能会缩放)。 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. 祝你好运,希望你能管理,我会留意你的任何参考资料。

I've had the same problem my normal webview wouldn't work and gave me the same error as you have described. 我遇到了同样的问题,我的普通webview无法正常工作,并且给了我与你所描述的相同的错误。

skip viewSizeChanged as w is 0

As I understand it this has to do with Android zoom which newer devices allows in order to avoid applications (designed for phones) appear as small window applications on eg tablets. 据我所知,这与Android缩放有关,新设备允许这样做以避免应用程序(专为手机设计)在平板电脑上显示为小窗口应用程序。

My solution: 我的解决方案

WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setBuiltInZoomControls(true);

the last line setBuiltInZoomControls(true) made the issue disappear for me. 最后一行setBuiltInZoomControls(true)让我的问题消失了。 I hope this helps you! 我希望这可以帮助你!

[EDIT] This solution worked fine for me yesterday, however this morning I got the error again. [编辑]这个解决方案昨天对我很好,但是今天早上我又得到了错误。 This is probably not the solution. 这可能不是解决方案。 Sorry for misleading post. 很抱歉有误导性的帖子。

[EDIT2] Now I have changed my code and I haven't experienced the error again after that, I ran a test suite of 1000 iterations without fault. [编辑2]现在我已经更改了我的代码,之后我没有再次遇到错误,我运行了1000次迭代的测试套件而没有错误。 What solved my problem was that the url wasn't passed correctly to the webview. 解决了我的问题的原因是url没有正确传递给webview。 It got an empty string, after making sure that a correct url the problem disappeared. 它确定了一个正确的url问题消失后得到一个空字符串。 Hopefully this will help someone. 希望这会对某人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM