Software draw deprecated

Software draw in WebView is deprecated and only maintained for backward compatibility.

Reasons to avoid software draw

Software draw has many drawbacks compared to hardware-accelerated draws.

  • Software draw uses more memory.
  • Software draw is very slow.
  • Software draw has known missing features, such as <video> or <webgl>.
  • New features may not be supported.
  • Software draw is not maintained or well tested, and is often broken by updates. Fixes to software-draw-only bugs are considered low priority.

How to avoid software draws

Hardware acceleration is enabled by default for all Android versions that supports Chromium WebView. However apps should avoid accidentally disabling hardware acceleration for WebView.

  • Do not use android:hardwareAccelerated=false anywhere.
  • Do not call setLayerType(View.LAYER_TYPE_SOFTWARE) on WebView or any parent of WebView.
  • Do not call webview.onDraw or webview.draw directly.

Snapshot use case

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.

File bugs for crashes

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.