WebView in NestedScrollView gives Fatal signal 6 (SIGABRT) code -6 RenderThread

前端 未结 3 2014
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 15:50

I have an activity with a ViewPager and TabLayout as below:




        
相关标签:
3条回答
  • 2020-12-21 16:33

    i has same issue and then i added code delayed handler

    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 
    }
    
    0 讨论(0)
  • 2020-12-21 16:35

    I had a similar issue. In my case, the problem was with this code:

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

    I removed this line of code, and my app stoped crashing. I faced with this issue on Android N. BTW Hardware acceleration is enabled by default if your Target API level is >=14 and i think this line of code is redundant.

    0 讨论(0)
  • 2020-12-21 16:51

    Well, I found a way to get the behaviour I want. But not to fix the original problem.

    I found this StackOverflow post which suggested extending WebView and implementing NestedScrollingChild as has been done here (Apache2).

    This works perfectly. However, it is not a solution to the actual problem.

    The layout now reads

    <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>
    

    The only change being adding the layout_behavior.

    0 讨论(0)
提交回复
热议问题