Skip to content

fix(mobile): keep the shell's window insets out of the page WebView (OTA phase C follow-up) - #22549

Merged
Jinwoo-H merged 4 commits into
mainfrom
ota-fu-page-safe-area
Sep 23, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
ota-fu-page-safe-area

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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-edges SafeAreaView) pads 101/41 again and the screen header's SafeAreaView edges={['top']} pads 104 more, so header content starts at y=308.

Cause: Android WebView M144+ forwards systemBars/displayCutout to every WebView through env(safe-area-inset-*) (M139+ also resizes the visual viewport for ime()), regardless of viewport-fit and 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, never CONSUMED).

What

  • orca-mobile-web-shell (Android): in createWebView(), ViewCompat.setOnApplyWindowInsetsListener zeroes systemBars | displayCutout | ime and forwards the result with ViewCompat.onApplyWindowInsets (a listener replaces the view's own handling: Chromium's listener on P–R, onApplyWindowInsets on S+). ime is zeroed because the shell already shortens the WebView for the keyboard and the page reads visualViewport; otherwise M139+ would count the keyboard twice. iOS is untouched: contentInsetAdjustmentBehavior = .never and the padded WKWebView reports no insets.
  • Page document: no longer declares 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.Builder runs as SDK 0 and drops every type, so an assertion would pass on nothing; the module has no Robolectric.

Proof

  • Opus design review: nothing must change; listener verified against Chromium AwDisplayCutoutController for P–R and S+; no interference with react-native's inset dispatch or safe-area-context (leaf view, nothing consumed).
  • Emulator API 36 (WebView 133) cannot reproduce; no-regression pass identical before/after (host header text y=189 vs native 186, session 171 vs 168, keyboard: WebView ends 1848, live input 1830).
  • WebView 145 emulator (Android 17 image, 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).
  • Lead gate on a748823: tsc, ratchet, oxlint, oxfmt, quality, react-doctor, anti-slop, native-quality all 0; config/scripts 259 files / 2398 tests; mobile 867 files / 9474 tests; closure pins unmoved.

Needs a new native build to take effect on Android.

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
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4dbcb934-a703-4325-9ee5-1d91b788f57f

📥 Commits

Reviewing files that changed from the base of the PR and between 845db9e and a748823.

📒 Files selected for processing (3)
  • config/scripts/build-mobile-web-app-bundle.mjs
  • config/scripts/build-mobile-web-app-bundle.test.mjs
  • mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellView.kt

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The generated mobile web app HTML no longer includes viewport-fit=cover. A bundle test checks the emitted viewport value. On Android, the shell zeros system bar, display cutout, and IME insets before forwarding them to the WebView.

Merge Risk: ⚪ Minimal · up to a7488

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 statemen… 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…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: preventing shell window insets from reaching the page WebView. It is concise and specific.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Android shell zeroes the WebView's window insets — createWebView() installs a ViewCompat inset listener that zeroes systemBars | displayCutout | ime and 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's index.html viewport 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-fit is 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 9cdbc0c into main Sep 23, 2026
59 of 61 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-page-safe-area branch September 23, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant