After a while of usage, my App freezes during scrolling a WebView, saying “could not lock surface”

后端 未结 3 1072
你的背包
你的背包 2020-12-15 23:49

My Android app consists of several activities, each responsible for a single fragment (for now). My fragments are usually displayed/attached somewhat like this:



        
3条回答
  •  我在风中等你
    2020-12-16 00:47

    I finally found the issue. Switching off hardware acceleration for the WebView solves it.

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saved) {
        //...
        if (Utils.isKitkat()) {
            disableHardwareAcc();
        }
        //...
    }
    
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    protected void disableHardwareAcc() {
        mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    

提交回复
热议问题