Repository navigation
fix(mobile): keep the shell's window insets out of the page WebView (OTA phase C follow-up) - #22549
Conversation
The shell already pads the WebView out of the status and navigation bars. With viewport-fit=cover, Android's edge-to-edge WebView still reports the window's bar insets through env(safe-area-inset-*), which react-native-safe-area-context on web reads, so every page-side SafeAreaView padded a full bar a second time. Without it env() reads 0 and the shell's pad is the only one. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
WebView M144+ forwards the window's systemBars and displayCutout insets to CSS env(safe-area-inset-*) for every WebView, and Chromium applies them regardless of viewport-fit. The shell already pads the WebView out of both bars, so every page-side SafeAreaView (expo-router's DefaultNavigator and the session header) padded a bar a second time. M139+ likewise resizes the visual viewport for ime(), which the shell has already done by shortening the WebView. The WebView now sees those three types zeroed, per Android's "zeroing" approach (not CONSUMED, so later changes still reach it). A listener replaces the WebView's own onApplyWindowInsets, so the zeroed set is passed back into it. iOS needs nothing: the WKWebView uses contentInsetAdjustmentBehavior = .never inside the padded shell and reports zero insets. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The earlier comment claimed dropping viewport-fit=cover makes env() read 0 on Android; Chromium's WebView applies the safe area regardless of viewport-fit. The page simply never asks to extend under the bars, and the shell owns the safe area. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The transformation has no honest JVM test (the builder runs as SDK 0 there and drops every inset type), so it moves into MobileWebShellView.kt as private members instead of standing alone. The listener comment now covers both the P-R listener and the S+ onApplyWindowInsets path it replaces, and the page document's comment says the env() zeroing is Android's; on iOS the padded WKWebView reports none. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe generated mobile web app HTML no longer includes Merge Risk: ⚪ Minimal · up to No actionable issue remains in the reviewed viewport and Android inset changes. Complete normal build and device checks before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed context, implementation information, and test evidence. However, it omits required template content, including the linked issue, visual proof or an explicit N/A statement, the ELI5 section, checklist confirmations, and repository notes. Resolution Add the required template sections. Include a valid issue reference after “Fixes #”, provide before-and-after screenshots or videos for the behavior change, or state exactly “N/A” with a reason, and complete the ELI5, Testing, Notes, Review, boundary, and Checklist sections.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Android shell zeroes the WebView's window insets —
createWebView()installs aViewCompatinset listener that zeroessystemBars | displayCutout | imeand forwards the result, so Chromium's M144+env(safe-area-inset-*)forwarding and M139+ime()viewport resize stop stacking on top of the shell's own padding. - Generated page drops
viewport-fit=cover— the bundle'sindex.htmlviewport meta no longer asks to extend under the system bars; the shell owns the safe area on both platforms. - Builder test pins the viewport meta — asserts the exact new meta string and that
viewport-fitis absent, so re-adding it fails.
I checked the load-bearing external contracts against primary sources: WindowInsetsCompat.Builder(insets).setInsets(...) does not throw on older APIs (the base BuilderImpl stores the mask and applyInsetTypes zeros systemWindowInsets; no platform builder until API 29), and ViewCompat.setOnApplyWindowInsetsListener forwards through ViewCompat.onApplyWindowInsets / toWindowInsets() so Chromium sees the zeroed set on every dispatch path. The ime zeroing matches the shell's keyboard ownership in MobileWebShellScreen.tsx:180 (the shell shortens the view; the page reads visualViewport). iOS is unaffected — the padded WKWebView reports no insets either way. A new native build is required for the Android half, which the description already notes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Why
On a Samsung with a current WebView, the hybrid-shell page sits three status-bar heights down and short of the gesture bar. Measured (device px, status-bar/cutout inset 103, gesture bar 42): the shell already keeps the WebView at
[0,103]–[1080,2298], yet inside the page expo-router's injected default navigator (an all-edgesSafeAreaView) pads 101/41 again and the screen header'sSafeAreaView edges={['top']}pads 104 more, so header content starts at y=308.Cause: Android WebView M144+ forwards
systemBars/displayCutoutto every WebView throughenv(safe-area-inset-*)(M139+ also resizes the visual viewport forime()), regardless ofviewport-fitand of whether a parent already padded it. react-native-safe-area-context on web reads exactly those values, so every page-side safe-area consumer pads on top of the shell's pad. Android's guidance for a natively padded layout is to zero those inset types before they reach the WebView (Insets.NONE, neverCONSUMED).What
orca-mobile-web-shell(Android): increateWebView(),ViewCompat.setOnApplyWindowInsetsListenerzeroessystemBars | displayCutout | imeand forwards the result withViewCompat.onApplyWindowInsets(a listener replaces the view's own handling: Chromium's listener on P–R,onApplyWindowInsetson S+).imeis zeroed because the shell already shortens the WebView for the keyboard and the page readsvisualViewport; otherwise M139+ would count the keyboard twice. iOS is untouched:contentInsetAdjustmentBehavior = .neverand the padded WKWebView reports no insets.viewport-fit=cover; the page never asks to extend under the bars. Builder test pins the viewport meta.No Kotlin unit test: on the JVM
WindowInsetsCompat.Builderruns as SDK 0 and drops every type, so an assertion would pass on nothing; the module has no Robolectric.Proof
AwDisplayCutoutControllerfor P–R and S+; no interference with react-native's inset dispatch or safe-area-context (leaf view, nothing consumed).Pixel_API_37, 1280x2856, status bar 156 px, nav bar 72 px), same package, before APK → after APK, page served from the same desktop build:env(safe-area-inset-top/bottom)reads 52/24 CSS px before and 0/0 after; WebView bounds[0,156]–[1280,2784]in both. Host header text top 502 → 190 (native 186); session header text top 486 → 174 (native 168); session content bottom 2712 → 2784 (WebView bottom); keyboard case identical before/after (IME top 1848 = WebView bottom, input box bottom 1830).Needs a new native build to take effect on Android.