今早一上班就有客户的奔溃bug,具体复现步骤,开发者选项-强制gpu渲染,点开会奔溃的页面页面布局如下图
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.base.jsbridge2.WVJBWebView
android:layerType="software"
android:id="@+id/web_view_topman"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.example.base.jsbridge2.WVJBWebView>
</ScrollView>
</LinearLayout>
先说下为什么嵌套scrollView,因为加载的h5页面滑动回回弹,实在没办法才加的scrollView;
然后就出现奔溃了,奔溃日志如下
java.lang.IllegalStateException: Unable to create layer for WVJBWebView
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:6141)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
百度了一大堆都说 解决方法:
webView.setLayerType(View.LAYER_TYPE_NONE, null);
关闭硬件加速即可,也不能使用软件加速
但是用户他就是强制gpu渲染,我能怎么办,把他手机拿来关了吗。。。。
然后本着再研究研究的态度,然后我就继续看,
看到https://bugs.chromium.org/p/chromium/issues/detail?id=578150这个网友问题跟我一样,然后说是gpu渲染的大小是有限的,所以导致的奔溃,然后我就开始研究怎么解决渲染的问题,然后我发现这个代码有人说道
android:transitionGroup="true"
用法如下链接 https://blog.youkuaiyun.com/zhaostrong/article/details/79043142
但是我用了 还是没解决我的问题,暂时先到这吧,先记录下,找机会再研究下