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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MgMpRcWj6y82LxLiwcuzmN
This commit is contained in:
Claude
2026-06-23 20:58:09 +00:00
parent 17c6aba934
commit 0b5d7925fe
2 changed files with 17 additions and 0 deletions
@@ -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
@@ -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()