From 6c45246750b2d0e44bcd046541d4570e4405a0db Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 10 Jun 2026 20:39:23 +0200 Subject: [PATCH] fix(android): prevent WebView white screen on resume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop forcing LAYER_TYPE_HARDWARE on the WebView in the shared WebHelper.setupView() (used by both CapacitorMainActivity and the legacy FullscreenActivity). The forced view-level hardware layer renders the whole WebView into an off-screen GPU texture that can be released when the app is backgrounded and is not always repainted on resume — the likely cause of the blank/white screen reported after switching apps and returning. GPU acceleration is unaffected: it comes from android:hardwareAccelerated="true" in the manifest, not from this call. The original setLayerType(LAYER_TYPE_HARDWARE) was added in 2021's "feat: enable hardware acceleration" commit, likely under the misconception that it was required to enable acceleration. Note: the bug is device/GPU-specific and not locally reproducible, so this is unverified hardening rather than a confirmed fix. The competing cause — the WebView renderer process being killed under memory pressure (no onRenderProcessGone handler) — is a separate, higher-risk follow-up. --- .../superproductivity/webview/WebHelper.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/superproductivity/superproductivity/webview/WebHelper.kt b/android/app/src/main/java/com/superproductivity/superproductivity/webview/WebHelper.kt index 0b849f0252..e13942a1c0 100644 --- a/android/app/src/main/java/com/superproductivity/superproductivity/webview/WebHelper.kt +++ b/android/app/src/main/java/com/superproductivity/superproductivity/webview/WebHelper.kt @@ -23,7 +23,13 @@ class WebHelper { @SuppressLint("SetJavaScriptEnabled") fun setupView(wv: WebView, modifyUA: Boolean) : WebView { - wv.setLayerType(View.LAYER_TYPE_HARDWARE, null) + // Use the platform default layer type. Forcing LAYER_TYPE_HARDWARE (added in + // 2021's "enable hardware acceleration" commit) isn't needed for GPU + // acceleration — that comes from android:hardwareAccelerated="true" in the + // manifest. Rendering the WebView into a view-level off-screen texture is the + // likely cause of the blank/white screen some users report after backgrounding + // and returning (Play Store review; not locally reproducible). + wv.setLayerType(View.LAYER_TYPE_NONE, null) wv.isFocusableInTouchMode = true // Paint the WebView surface in the theme background so the adjustResize