Skip to content

fix(android): do not pad the WebView for the IME below API 30 - #8606

Open
ruffzy wants to merge 1 commit into
ionic-team:mainfrom
ruffzy:fix/android-ime-padding-api29
Open

ruffzy wants to merge 1 commit into
ionic-team:mainfrom
ruffzy:fix/android-ime-padding-api29

Conversation

@ruffzy

@ruffzy ruffzy commented Sep 16, 2026

Copy link
Copy Markdown

Fixes #8601

What

SystemBars.initWindowInsetsListener applies the ime() inset as bottom padding while the keyboard is visible. On API 29 that padding is applied on top of a window the system has already resized for the keyboard (windowSoftInputMode="adjustResize"), and WindowInsetsCompat.Type.ime() is only an approximation below API 30. The WebView is therefore shrunk twice.

This PR only applies the IME padding on API 30+, where ime() reports the real overlap. Both padding sites in the listener (passthrough and non-passthrough branch) use the same guard. Behaviour on API 30+ is unchanged.

Reproduction

  • Android 10 (API 29), Android System WebView ≥ 140, page declares viewport-fit=cover
  • @capacitor/android 8.4.1 and 8.5.2 both affected
  • Focus any input: window.innerHeight drops from 743 to 141 CSS px instead of the expected ~443; dumpsys activity top shows the parent at full height (0,0-1080,2231) and CapacitorWebView at 0,0-1080,327.
  • Rotate with the keyboard open and back: WebView stays at 109 px until the app is restarted.

Newer devices (API 30+) are not affected because ime() reports the correct value there, and the Google API 29 emulator image ships WebView 91 (< 140), so the passthrough branch never runs on it — a physical device with a Play Store WebView is needed to reproduce.

Verification

Applied via patch-package to @capacitor/android 8.4.1 in a production app and tested on a Huawei MAR-LX1A (Android 10, WebView 152):

State before after
keyboard open innerHeight 141, footer hidden 442, footer visible above keyboard
rotate with keyboard, back to portrait stuck at 109 442
keyboard closed 743 743
Pixel 7 Pro emulator, Android 14, keyboard open 515 515 (unchanged)
Samsung Galaxy A35 (SM-A356B), Android 14, WebView 151, keyboard open / rotate / close 441, footer visible / 441 / 751 (unchanged, passthrough branch exercised)

compileReleaseJavaWithJavac, testReleaseUnitTest and the Prettier Java check pass. The non-passthrough branch (WebView < 140) received the same guard for consistency but was not exercised on a device.

🤖 Generated with Claude Code

On API 29 the window is already resized by the system when the keyboard
opens (windowSoftInputMode="adjustResize"), and WindowInsetsCompat can
only approximate the ime() inset there. SystemBars additionally applied
that approximated height as bottom padding, so the WebView was shrunk
twice and collapsed to a few hundred pixels whenever WebView >= 140 and
viewport-fit=cover were in use. After a rotation with the keyboard open
the stale padding stuck until the app was restarted.

Only apply the IME padding on API 30+, where ime() reports the real
overlap. Verified on a Huawei MAR-LX1A (Android 10, WebView 152):
window.innerHeight with the keyboard open is now 442 instead of 141
CSS px, and rotating with the keyboard open no longer leaves the WebView
stuck. Behaviour on API 30+ is unchanged.

Fixes ionic-team#8601

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

[Bug]: SystemBars shrinks the WebView twice for the keyboard on Android 10 (API 29) when WebView >= 140 and viewport-fit=cover

1 participant