From 0b5d7925fe91ba55d04f0c9459cda30d440efbfe Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 23 Jun 2026 20:58:09 +0000 Subject: [PATCH] chore: temporary diagnostics for embedded browser scrolling Adds two temporary logs to pin down why the embedded browser doesn't scroll: - provider side (NappletBrowserService): logs each MotionEvent that reaches the remote WebView, so we can see if touch crosses the SurfaceControlViewHost boundary at all (returns false, never consumes). - client side (EmbeddedBrowserController): logs the SandboxedSdkView session state transitions (Idle/Loading/Active/Error). To be reverted once the cause is confirmed. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01MgMpRcWj6y82LxLiwcuzmN --- .../loggedIn/browser/EmbeddedBrowserController.kt | 11 +++++++++++ .../amethyst/napplethost/NappletBrowserService.kt | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/EmbeddedBrowserController.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/EmbeddedBrowserController.kt index 928c1b298e..b374235e23 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/EmbeddedBrowserController.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/EmbeddedBrowserController.kt @@ -31,8 +31,11 @@ import android.os.IBinder import android.os.Looper import android.os.Message import android.os.Messenger +import android.util.Log import androidx.annotation.RequiresApi import androidx.privacysandbox.ui.client.SandboxedUiAdapterFactory +import androidx.privacysandbox.ui.client.view.SandboxedSdkUiSessionState +import androidx.privacysandbox.ui.client.view.SandboxedSdkUiSessionStateChangedListener import androidx.privacysandbox.ui.client.view.SandboxedSdkView import androidx.privacysandbox.ui.core.SandboxedUiAdapter import com.vitorpamplona.amethyst.napplethost.NappletBrowserContract @@ -98,6 +101,14 @@ class EmbeddedBrowserController( // Paint the surface placeholder in the app's theme background so there's no white flash before // the remote WebView delivers its first frame. view.setBackgroundColor(backgroundColor) + // DIAGNOSTIC (scrolling): log the surface session lifecycle so we can see if it reaches Active. + view.addStateChangedListener( + object : SandboxedSdkUiSessionStateChangedListener { + override fun onStateChanged(state: SandboxedSdkUiSessionState) { + Log.w("BrowserSurfaceDiag", "DIAG session state: $state") + } + }, + ) pendingAdapter?.let { view.setAdapter(it) pendingAdapter = null diff --git a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletBrowserService.kt b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletBrowserService.kt index 56f3566cda..4ed48584bc 100644 --- a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletBrowserService.kt +++ b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletBrowserService.kt @@ -161,6 +161,12 @@ class NappletBrowserService : Service() { configureWebView(wv) // Theme the pre-load background so a blank/loading page shows Amethyst's background, not white. wv.setBackgroundColor(bgColor) + // DIAGNOSTIC (scrolling): log whether touch input crosses the SurfaceControlViewHost boundary to + // the remote WebView at all. Returns false so it never consumes — the WebView still scrolls. + wv.setOnTouchListener { _, event -> + Log.w(TAG, "DIAG browser WebView touch action=${event.actionMasked} x=${event.x} y=${event.y}") + false + } wv.dropSystemBarInsets() applyWebViewProxy(if (useTor) proxyPort else -1) val shim = readContractAsset(NappletWebContract.SHIM_JS_PATH).decodeToString()