【问题标题】:Android webview crashes randomly due to SSE call由于 SSE 调用,Android webview 随机崩溃
【发布时间】:2014-02-16 10:21:50
【问题描述】:

我有一个带有 Jquery 2.0 网页的 Jquery Mobile 1.4,我在 Android Webview (Android 4+) 中提供该网页。在我开始使用 SSE 之前,一切都很好。由于 WebViewCoreThread 上的 Signal 11,应用程序会定期崩溃。

这种情况仅在在页面之间导航时发生,然后随机发生。

没有堆栈跟踪,只有 0x00000000 处的信号 11。

这是javascript代码:

if ( typeof (EventSource) !== "undefined") {
    // sse
    //console.log("sse");
    chatnotificationsource = new EventSource("php/process_get_chat_notification.php");
    chatnotificationsource.onmessage = function(event) {

        var message = event.data;
        console.log("got message " + message);
        $("#chatnotification").show();

    };
}

当我关闭 SSE 代码时没有问题,因此它显然与 SSE 调用有关。我正在使用以下 WebView 初始化。

    @SuppressLint("SetJavaScriptEnabled")
protected void createWebView(int webViewId) {

    webView = (WebView) findViewById(webViewId);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);

    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setAppCacheMaxSize(20 * 1024 * 1024); // 20MB
    webView.getSettings().setAppCachePath(
            getApplicationContext().getCacheDir().getAbsolutePath());
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setAppCacheEnabled(true);
    // load online by default
    webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    if (!connectionDetector.isConnectingToInternet()) {
        // loading offline
        webView.getSettings().setCacheMode(
                WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }

    // clients
    webView.setWebViewClient(customWebViewClient);
    webView.setWebChromeClient(customWebChromeClient);

}

我希望这与 Android 在 SSE 调用正在运行或“处理”时导航到另一个页面有关。

感谢您的帮助, 科诺斯

【问题讨论】:

  • 没人?我从 Webview 服务的页面中删除了 SSE 调用,并且再也没有出现崩溃。
  • 您解决了这个问题吗?我有同样的问题。如果运行 Jquery 代码会随机崩溃。期待更多信息。谢谢。
  • 不,我没有,我离开了 SSE 和 webview。

标签: android jquery-mobile android-webview server-sent-events


【解决方案1】:

脱离 SSE 并结合 Android WebView 解决了这个问题。 (目前)还没有 WebView 补丁/更新或解决方法。

【讨论】:

    猜你喜欢
    • 2013-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 2013-12-24
    • 2019-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多