美文网首页
android webview 多进程crash

android webview 多进程crash

作者: couriravant | 来源:发表于2022-09-08 18:37 被阅读0次

    两种方法:

    一、 直接禁止非主进程的webview
    在 application onCreate 中

     isRunningInMainProcess = ProcessUtils.isRunningInMainProcess(AppContext.getContext(), true);
            if (!isRunningInMainProcess && Build.VERSION.SDK_INT >=  Build.VERSION_CODES.P) {
                try{
                    WebView.disableWebView();
                } catch (Exception e) {
                    MDLog.e("MomoApplication","application init exception: "+ e.getMessage());
                }
            }
    

    应该是治本的方法,但是需要在太靠前的位置,不太敢直接上线跑
    二、 网上一个自己尝试加锁的方法:
    https://yuweiguocn.github.io/android-multiprocess-webview/
    https://juejin.cn/post/6950091477192015902
    这种方法可以避免启动时的crash,但是启动后的,应该就没啥用了。。

    第二种方法注意,有个相关crash,关于webview gpu的,一般表现在native crash,这个应该注意下覆盖安装删除webview 缓存目录(华为单独生成了个目录,加了hws)下的非Webview_data.lock文件

    image.png

    另外一个比较靠谱的web crash 集锦:
    https://www.infoq.cn/article/y3ahox4xfqchp6uyisqb

    相关文章

      网友评论

          本文标题:android webview 多进程crash

          本文链接:https://www.haomeiwen.com/subject/cplznrtx.html