【问题标题】:WebView in NestedScrollView gives Fatal signal 6 (SIGABRT) code -6 RenderThreadNestedScrollView 中的 WebView 给出致命信号 6 (SIGABRT) 代码 -6 RenderThread
【发布时间】:2017-03-07 15:49:45
【问题描述】:

我有一个带有 ViewPager 和 TabLayout 的活动,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/item_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/item_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="0dp"
            app:layout_scrollFlags="scroll|enterAlwaysCollapsed">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/item_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </android.support.design.widget.TabLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/item_viewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

    </android.support.v4.view.ViewPager>

</android.support.design.widget.CoordinatorLayout>

其中一个片段是 WebView。为了在 WebView 滚动时隐藏工具栏,我在 NestedScrollView 中有 WebView。

在添加 NestedScrollView 之前,应用运行良好,但没有隐藏工具栏。

现在,一旦 WebView 完成加载,应用就会关闭且没有 Java 堆栈跟踪。

片段布局如下

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:id="@+id/browser_root"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ProgressBar
        android:id="@+id/browser_loading_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminateTintMode="src_atop"
        android:indeterminateTint="@color/colorAccent"
        android:layout_gravity="center"/>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <WebView
            android:id="@+id/browser_webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible">

        </WebView>

    </android.support.v4.widget.NestedScrollView>



</LinearLayout>

当要加载某些内容时,会调用 mWebView.loadUrl。 WebView 有一个客户端,因此当页面加载完成时,Spinner 可见性设置为消失,WebView 可见。

Android 监视器显示:

10-25 15:22:12.111 3871-3871/com.tpb.hn I/Browser: loadURL: WebView loading
10-25 15:22:12.113 3871-3871/com.tpb.hn I/cr_Ime: ImeThread is not enabled.
10-25 15:22:12.118 3871-3911/com.tpb.hn I/OpenGLRenderer: Initialized EGL, version 1.4
10-25 15:22:12.118 3871-3911/com.tpb.hn D/OpenGLRenderer: Swap behavior 1

                                                          [ 10-25 15:22:12.118  3871: 3911 D/         ]
                                                          HostConnection::get() New Host Connection established 0x7ffeeca88c00, tid 3911
10-25 15:22:12.126 3871-3936/com.tpb.hn E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
10-25 15:22:12.136 3871-3936/com.tpb.hn I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es

                                                             [ 10-25 15:22:12.138  3871: 3936 D/         ]
                                                             HostConnection::get() New Host Connection established 0x7ffeeb7fe080, tid 3936
10-25 15:22:12.219 3871-3871/com.tpb.hn W/chromium: [WARNING:shell.cc(299)] Instance: exe:chrome attempting to register an instance for a process it created for target: exe:chrome_renderer without the mojo:shell{client_process} capability class.
10-25 15:22:12.317 3871-3871/com.tpb.hn W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3871
10-25 15:22:12.317 3871-3871/com.tpb.hn D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
10-25 15:22:12.418 3871-3876/com.tpb.hn I/art: Do partial code cache collection, code=24KB, data=29KB
10-25 15:22:12.419 3871-3876/com.tpb.hn I/art: After code cache collection, code=24KB, data=29KB
10-25 15:22:12.419 3871-3876/com.tpb.hn I/art: Increasing code cache capacity to 128KB
10-25 15:22:12.635 3871-3871/com.tpb.hn I/HNLoader: onResponse: [I@842b545
10-25 15:22:12.635 3871-3871/com.tpb.hn I/ContentAdapter: IdLoadDone: 
10-25 15:22:13.673 3871-3876/com.tpb.hn I/art: Do partial code cache collection, code=55KB, data=61KB
10-25 15:22:13.673 3871-3876/com.tpb.hn I/art: After code cache collection, code=55KB, data=61KB
10-25 15:22:13.673 3871-3876/com.tpb.hn I/art: Increasing code cache capacity to 256KB
10-25 15:22:13.765 3871-3871/com.tpb.hn W/art: Attempt to remove non-JNI local reference, dumping thread
10-25 15:22:13.766 3871-3911/com.tpb.hn E/OpenGLRenderer: GL error:  GL_INVALID_VALUE
10-25 15:22:13.766 3871-3911/com.tpb.hn A/OpenGLRenderer: GL errors! frameworks/base/libs/hwui/BakedOpRenderer.cpp:66

                                                          --------- beginning of crash
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: Chrome build fingerprint:
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: 1.0
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: 1
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: f3e1957e-ea20-4058-8e10-b7e303fde16a
10-25 15:22:13.788 3871-3911/com.tpb.hn W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
10-25 15:22:13.788 3871-3911/com.tpb.hn A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3911 (RenderThread)

                                                [ 10-25 15:22:13.788  1181: 1181 W/         ]
                                                debuggerd: handling request: pid=3871 uid=10066 gid=10066 tid=3911

loadUrl 是 WebView 开始加载的时间

我已阅读有关致命信号 6 代码 -6 的帖子,但没有人提供解决方案。

非常感谢任何帮助。

编辑-我删除了 WebView 的默认不可见性,以及更改它的代码,并获得了更大的跟踪和更多的细节。

我无法在此处发布,因为帖子的长度为 59000 个字符,但现在在 PasteBin Here

【问题讨论】:

    标签: android android-fragments webview sigabrt


    【解决方案1】:

    我遇到了类似的问题。就我而言,问题出在这段代码上:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    

    我删除了这行代码,我的应用程序不再崩溃。我在 Android N 上遇到了这个问题。 BTW Hardware acceleration is enabled by default if your Target API level is &gt;=14 我认为这行代码是多余的。

    【讨论】:

    • 这里也一样。它只导致一台测试设备,现在消失了!
    【解决方案2】:

    嗯,我找到了一种方法来获得我想要的行为。但不是为了解决原来的问题。

    我发现 this StackOverflow 帖子建议扩展 WebView 并实现 NestedScrollingChild,就像 here (Apache2) 所做的那样。

    这非常有效。但是,这并不能解决实际问题。

    现在布局显示

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:app="http://schemas.android.com/apk/res-auto"
                  android:id="@+id/browser_root"
                  android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent">
    
        <ProgressBar
            android:id="@+id/browser_loading_spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminateTintMode="src_atop"
            android:indeterminateTint="@color/colorAccent"
            android:layout_gravity="center"/>
    
    
            <com.tpb.hn.story.NestedWebView
                android:id="@+id/browser_webview"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="invisible">
    
            </com.tpb.hn.story.NestedWebView>
    
    
    
    </LinearLayout>
    

    唯一的变化是添加 layout_behavior。

    【讨论】:

      【解决方案3】:

      我有同样的问题 然后我添加了代码延迟处理程序

      private void loadJavaScript(String script) {
          mHandler.postDelayed(new Runnable() {
              @Override
              public void run() {
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                      if (mWebView != null) {
                          mWebView.evaluateJavascript(script, null);
                          return;
                      }
                  }
      
                  loadPage("javascript:" + script);
              }
          }, 500); //this 
      }
      

      【讨论】:

        猜你喜欢
        • 2014-04-29
        • 2014-12-21
        • 2016-01-05
        • 2014-06-25
        • 2015-07-19
        • 1970-01-01
        • 2020-05-01
        • 2017-02-27
        相关资源
        最近更新 更多