错误/Web 控制台:未捕获错误:卸载处理程序花费太多时间

发布于 2024-12-11 01:58:46 字数 208 浏览 1 评论 0原文

当我通过 WebView 加载 url 时,有时会收到大量如下消息:

10-19 19:18:38.056: ERROR/Web Console(6524): 
Uncaught Error: Too much time spent in unload handler. at v8/DateExtension:1

此错误是什么意思?

When I load a url via WebView, I sometimes receive a flood of numerous messages like this:

10-19 19:18:38.056: ERROR/Web Console(6524): 
Uncaught Error: Too much time spent in unload handler. at v8/DateExtension:1

What does this error mean?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白云悠悠 2024-12-18 01:58:46

这似乎是在 webkit 中的 DateExtension.cpp 中定义的。这是一个 C++ 异常,如果调用 JS 钩子(如果设置了enableSleepDetection(true),则插入到 Date.getTime 中)超过 1000 次,则会引发该异常。

您可能需要获取 Android 源代码以进行更多研究。该文件没有任何文档。

This appears to be defined in DateExtension.cpp, in webkit. It's a C++ exception that is thrown if a JS hook (inserted into Date.getTime, if enableSleepDetection(true) is set) is called more than 1000 times.

You might want to fetch the Android source code to look into it more. There's no documentation on the file.

2024-12-18 01:58:46

我遇到了同样的错误。经过一番调查后我解决了这个问题。
也许这段代码会对您有所帮助:

        {
            webView = (WebView) view.findViewById(R.id.transcationwebview);
                progressdialog = ProgressDialog.show(mContext, "",
                        mContext.getString(R.string.please_wait));
                progressdialog.setCancelable(true);
                progressdialog.setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface dialog) {
                        webView.stopLoading();
                        // webView.clearView();

                    }
                });



                webView.setWebChromeClient(new MyChromeClient());
                webView.getSettings().setBuiltInZoomControls(true);
                webView.getSettings().setLayoutAlgorithm(
                        WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
                webView.getSettings().setUseWideViewPort(true);
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        // TODO Auto-generated method stub
                        // view.loadUrl(url);
                        return false;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        // TODO Auto-generated method stub
                        super.onPageFinished(view, url);
                        if (progressdialog != null && progressdialog.isShowing()) {
                            progressdialog.dismiss();
                        } 

                    }

                    @Override
                    public void onPageStarted(WebView view, String url, Bitmap favicon) {
                        // TODO Auto-generated method stub
                        super.onPageStarted(view, url, favicon);
                    }

                    @Override
                    public void onReceivedError(WebView view, int errorCode,
                            String description, String failingUrl) {
                        // TODO Auto-generated method stub



                    }
                });
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.getSettings().setPluginState(PluginState.ON);
                webView.getSettings().setBuiltInZoomControls(true);
                webView.getSettings().setPluginsEnabled(true);
                webView.setKeepScreenOn(true);
                webView.getSettings().setDomStorageEnabled(true);
                webView.getSettings().setAppCacheEnabled(true);
                webView.getSettings().setJavaScriptEnabled(true);
                webView.loadUrl(url);
}
    public class MyChromeClient extends WebChromeClient {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                try {

                    if (progressdialog.isShowing()) {
                        progressdialog.setMessage(getString(R.string.loading)
                                + newProgress + " %");

                    } else {
                        /*
                         * webView.stopLoading(); webView.clearView();
                         */
                    }
                } catch (Throwable e) {

                    e.printStackTrace();
                }
            }

I got the same error. After some investigating I have solved this issue.
Maybe this code will help you:

        {
            webView = (WebView) view.findViewById(R.id.transcationwebview);
                progressdialog = ProgressDialog.show(mContext, "",
                        mContext.getString(R.string.please_wait));
                progressdialog.setCancelable(true);
                progressdialog.setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface dialog) {
                        webView.stopLoading();
                        // webView.clearView();

                    }
                });



                webView.setWebChromeClient(new MyChromeClient());
                webView.getSettings().setBuiltInZoomControls(true);
                webView.getSettings().setLayoutAlgorithm(
                        WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
                webView.getSettings().setUseWideViewPort(true);
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        // TODO Auto-generated method stub
                        // view.loadUrl(url);
                        return false;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        // TODO Auto-generated method stub
                        super.onPageFinished(view, url);
                        if (progressdialog != null && progressdialog.isShowing()) {
                            progressdialog.dismiss();
                        } 

                    }

                    @Override
                    public void onPageStarted(WebView view, String url, Bitmap favicon) {
                        // TODO Auto-generated method stub
                        super.onPageStarted(view, url, favicon);
                    }

                    @Override
                    public void onReceivedError(WebView view, int errorCode,
                            String description, String failingUrl) {
                        // TODO Auto-generated method stub



                    }
                });
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.getSettings().setPluginState(PluginState.ON);
                webView.getSettings().setBuiltInZoomControls(true);
                webView.getSettings().setPluginsEnabled(true);
                webView.setKeepScreenOn(true);
                webView.getSettings().setDomStorageEnabled(true);
                webView.getSettings().setAppCacheEnabled(true);
                webView.getSettings().setJavaScriptEnabled(true);
                webView.loadUrl(url);
}
    public class MyChromeClient extends WebChromeClient {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                try {

                    if (progressdialog.isShowing()) {
                        progressdialog.setMessage(getString(R.string.loading)
                                + newProgress + " %");

                    } else {
                        /*
                         * webView.stopLoading(); webView.clearView();
                         */
                    }
                } catch (Throwable e) {

                    e.printStackTrace();
                }
            }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文