Strip IME insets from browser WebView to prevent double padding - #9396
Open
lmac012 wants to merge 1 commit into
Open
Strip IME insets from browser WebView to prevent double padding#9396lmac012 wants to merge 1 commit into
lmac012 wants to merge 1 commit into
Conversation
lmac012
marked this pull request as draft
August 5, 2026 10:13
Since WebView M139 the WebView subtracts any IME inset it receives from
its visual viewport ("WebView-Window intersection" resizing). The browser
layout already resizes for the keyboard, so during IME entry both
mechanisms applied within the same frame, transiently collapsing the
visual viewport (e.g. 455dp -> 135dp on a Pixel 8). Sites that react to
visualViewport resize by clearing element focus (e.g. the
gemini.google.com composer) blurred the focused editor, making Chromium
dismiss the keyboard ~90ms after showing it.
Zero out ime() insets before they reach the WebView, as recommended in
https://developer.android.com/develop/ui/views/layout/webapps/understand-window-insets
The behavior is opt-in via DuckDuckGoWebView.setStripImeInsetsEnabled(),
enabled for the browser tab WebView behind the
androidBrowserConfig.stripWebViewImeInsets sub-feature (enabled by
default; the remote flag acts as a kill switch).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lmac012
force-pushed
the
fix/lukasz/webview-keyboard-inset
branch
from
August 5, 2026 11:20
393a0ea to
77eed60
Compare
lmac012
marked this pull request as ready for review
August 5, 2026 11:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task/Issue URL: https://app.asana.com/1/137249556945/project/1205617573940217/task/1217145253883158?focus=true
Tech Design URL (if applicable):
API Proposals URL(s) (if applicable):
Description
Since WebView M139, the WebView shrinks its visual viewport by any IME inset it receives. Our layout already resizes for the keyboard, so during IME entry both mechanisms briefly apply at once, transiently collapsing the visual viewport. This was confirmed to cause breakage on gemini.google.com, where collapsing the visual viewport clears composer focus and hides the on-screen keyboard, making it nearly impossible to use the site.
Fix: zero out
ime()insets before they reach the browser WebView, as recommended in Google's WebView insets guidance.Steps to test this PR
Keyboard stays open on Gemini
Kill switch
androidBrowserConfig>stripWebViewImeInsetsin internal feature flag settingsNo UI changes
Note
Medium Risk
Changes keyboard and viewport behavior for all in-app browsing when enabled; mitigated by a remote kill switch and a narrow inset adjustment.
Overview
Fixes keyboard dismissal and visual viewport collapse on sites like Gemini when WebView M139 shrinks the visual viewport for IME insets while the browser layout already resizes for the keyboard.
DuckDuckGoWebViewnow optionally zerosime()insets inonApplyWindowInsetsbefore they reach the WebView, following Android’s WebView inset guidance.BrowserTabFragmentenables this viasetStripImeInsetsEnabledafter readingandroidBrowserConfig.stripWebViewImeInsets(defaults on). Disabling the flag restores the old double-padding behavior for verification.Reviewed by Cursor Bugbot for commit 77eed60. Bugbot is set up for automated code reviews on this repo. Configure here.