Android WebView OffscreenCanvas renders correctly in Web Worker but is not composited / shows blank after Activity resume
**Platform:** Android native app (Java / Kotlin)
**WebView:** Android WebView with hardware acceleration enabled
**Android version:** Android 10
**WebView version / Chrome version:** 100.0.4896.127
**Device:** [Oppo, Huawei]
Architecture:
Two Activities: MainActivity and SecondActivity
MainActivity contains a WebView
The WebView loads an HTML page
The page uses canvas.transferControlToOffscreen()
Rendering is performed in a Web Worker using OffscreenCanvas
I want content rendered with OffscreenCanvas to continue displaying correctly after the user navigates away from MainActivity and then returns.
Launch MainActivity
WebView loads the HTML page
The page transfers control of a <canvas> to a Web Worker via transferControlToOffscreen()
The Web Worker renders content into the OffscreenCanvas ✅
The content is displayed correctly on screen ✅
Navigate from MainActivity to ArticleActivity
Return to MainActivity
WebView.onResume() is called in MainActivity.onResume()
Trigger a re-render or UI update that causes the canvas content to change
The OffscreenCanvas content should be displayed correctly after returning to MainActivity.
After returning to MainActivity, the OffscreenCanvas area becomes completely blank when the content is re-rendered or updated.
When the canvas appears blank, calling:
canvas.toDataURL()
from JavaScript successfully returns the complete and correct image data.
This proves that:
✅ The Web Worker is rendering correctly
✅ Pixel data is written to the OffscreenCanvas backing buffer
✅ The issue is not in the JavaScript or rendering logic
After the blank screen appears, calling:
location.reload()
does not fix the issue. The entire page, JavaScript context, Web Worker, and transferControlToOffscreen() are re-initialized, but the canvas still does not display.
This suggests the underlying Android WebView rendering pipeline / GPU context is corrupted or not restored, rather than the JS state.
JavaScript / rendering side
Resizing the canvas
Forcing reflow / repaint
Using requestAnimationFrame
Re-submitting frames from the Worker
Android / WebView side
Calling webView.onResume() in onResume()
Calling webView.postInvalidate()
Forcing rendering via webView.evaluateJavascript(...)
Toggling setLayerType() between:
LAYER_TYPE_HARDWARE
LAYER_TYPE_SOFTWARE
Recreating the OffscreenCanvas on visibilitychange
None of these approaches resolved the issue.
How can I restore OffscreenCanvas display after Activity resume, without recreating the WebView or reloading the page?
Any guidance, official API, Chromium-internal insight, or a confirmed workaround would be appreciated.
https://github.com/y1j2x34/android-webview-offscreencanvas-issue