首页 > 解决方案 > Android WebView播放视频报错闪黑屏

问题描述

嗨,我正在从 webview 编写应用程序,当在 webview 中播放视频时,有时会出现错误,并且手机屏幕开始闪烁白黑。

看录屏https://youtu.be/ST8fc0w_Um8

并在日志 android studio

2020-07-30 11:14:51.575 32584-310/ru.example E/chromium: [ERROR:image_reader_gl_owner.cc(263)] no buffers currently available in the reader queue
2020-07-30 11:14:51.613 32584-310/ru.example E/chromium: [ERROR:shared_image_factory.cc(471)] CreateSharedImage: could not create backing.
2020-07-30 11:14:51.614 32584-310/ru.example E/chromium: [ERROR:shared_image_stub.cc(169)] SharedImageStub: Unable to create shared image
2020-07-30 11:14:51.624 32584-32643/ru.example E/chromium: [ERROR:shared_image_manager.cc(141)] SharedImageManager::ProduceGLTexture: Trying to produce a representation from a non-existent mailbox. 48:86:2E:E3:73:35:1E:70:B4:F7:83:AD:17:E1:CE:8F
2020-07-30 11:14:51.624 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(18937)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]GL ERROR :GL_INVALID_OPERATION : DoCreateAndTexStorage2DSharedImageINTERNAL: invalid mailbox name
2020-07-30 11:14:51.624 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(18958)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]GL ERROR :GL_INVALID_OPERATION : DoBeginSharedImageAccessCHROMIUM: bound texture is not a shared image
2020-07-30 11:14:51.624 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(18987)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]GL ERROR :GL_INVALID_OPERATION : DoEndSharedImageAccessCHROMIUM: bound texture is not a shared image
2020-07-30 11:14:51.624 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(18958)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]GL ERROR :GL_INVALID_OPERATION : DoBeginSharedImageAccessCHROMIUM: bound texture is not a shared image
2020-07-30 11:14:51.625 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(10716)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]RENDER WARNING: texture bound to texture unit 0 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)?
2020-07-30 11:14:51.626 32584-32643/ru.example E/chromium: [ERROR:gles2_cmd_decoder.cc(18987)] [GroupMarkerNotSet(crbug.com/242999)!:B89A0D1A74000000]GL ERROR :GL_INVALID_OPERATION : DoEndSharedImageAccessCHROMIUM: bound texture is not a shared image
2020-07-30 11:14:51.712 32584-310/ru.example E/chromium: [ERROR:shared_image_factory.cc(471)] CreateSharedImage: could not create backing.
2020-07-30 11:14:51.712 32584-310/ru.example E/chromium: [ERROR:shared_image_stub.cc(169)] SharedImageStub: Unable to create shared image
2020-07-30 11:14:51.729 32584-32643/ru.example E/chromium: [ERROR:shared_image_manager.cc(141)] SharedImageManager::ProduceGLTexture: Trying to produce a representation from a non-existent mailbox. 7E:1A:65:59:81:24:B8:07:83:A5:48:04:2B:51:A5:59

我的网页浏览设置

View rootView = inflater.inflate(R.layout.fragment, container, false);

        WebView = (ObservableWebView) rootView.findViewById(R.id.WebView);

        WebView.setVerticalScrollBarEnabled(false);
        WebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);

        WebView.setFocusable(true);
        WebView.setFocusableInTouchMode(true);

        WebView.getSettings().setJavaScriptEnabled(true);
        WebView.getSettings().setDomStorageEnabled(true);
        WebView.getSettings().setAppCacheEnabled(true);


        WebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

        WebView.getSettings().setAllowFileAccessFromFileURLs(true);
        WebView.getSettings().setAllowUniversalAccessFromFileURLs(true);

        WebView.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
        WebView.getSettings().setMediaPlaybackRequiresUserGesture(false);

        ///WebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        //WebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

        WebView.setWebChromeClient(new WebChromeClient());
        WebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(android.webkit.WebView view, String url) {
                if(appBarHeight==0){
                    appBarHeight=((MainActivity) getContext()).getHeightPanel();
                }
                super.onPageFinished(view, url);
            }

        });
        WebView.addJavascriptInterface(new JavascriptBridge(WebView), "Android");

请帮助解决这个问题

标签: androidvideowebviewscreenblink

解决方案


推荐阅读