Software draw in WebView is deprecated and only maintained for backward compatibility.
Software draw has many drawbacks compared to hardware-accelerated draws.
<video>
or <webgl>
.Hardware acceleration is enabled by default for all Android versions that supports Chromium WebView. However apps should avoid accidentally disabling hardware acceleration for WebView.
android:hardwareAccelerated=false
anywhere.setLayerType(View.LAYER_TYPE_SOFTWARE)
on WebView or any parent of WebView.webview.onDraw
or webview.draw
directly.A common use case for software draw is to obtain an image or texture snapshot of the WebView. The officially supported way to do this is to create a VirtualDisplay backed by a SurfaceTexture.
VirtualDisplay can be used to create a Presentation and the WebView can be attached to the Presentation. WebView will then render into the SurfaceTexture of the VirtualDisplay.
SurfaceTexture can be consumed as a texture in OpenGL which can then be readback into a Bitmap.
If you are disabling hardware acceleration to avoid crashes, then please file a bug at https://bugs.chromium.org/p/chromium/issues/entry?template=Webview+Bugs. Please include the apk of the app, exact steps to reproduce the crash, and the build fingerprint of the device. The fingerprint can be obtained with adb shell getprop ro.build.fingerprint
.