Skip to content

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Dec 8, 2025

Fixes #175074

There was an implicit expectation in the resizing code: When the virtual keyboard is up on mobile, the view's physicalSize remains fixed, and any resizes (presumably caused by the virtual keyboard itself) should be considered as viewInsets.

This expectation was broken inadvertently by my PR: #172493


The sequence of events that lead to the reported issue:

  1. View's physical size is calculated based on window size.
  2. Text editing starts, virtual keyboard comes up.
  3. View's physical size remains unchanged, and the difference caused by the keyboard is reported as view insets to the framework.
  4. (so far so good).
  5. When resizeToAvoidBottomInset is true, the framework will re-render its content to fit the available size.
  6. The new render call comes with a new size that's basically physical height - bottom inset.
  7. The engine takes that new size and applies it to the DOM.
  8. (now the view's DOM element has been resized incorrectly).
  9. ...
  10. Eventually, this leads to the new insets being calculated incorrectly resulting in negative insets which cause the framework to throw.

The fix involves the following:

  1. Respect the expectation mentioned above: when the keyboard is up, view's physical size should remain unchanged.
  2. If we ever end up with negative insets, catch it earlier in the engine so it's easier to debug the root cause.
  3. New regression test.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Dec 8, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a regression on Android web where resizeToAvoidBottomInset was not functioning correctly when the virtual keyboard is displayed. The fix ensures that the view's physicalSize is not updated by framework-initiated resizes while the keyboard is active, preserving the correct layout behavior. The changes include renaming methods for clarity, such as _didResize to _handleBrowserResize, and introducing a new getter _shouldPreservePhysicalSizeOnResize to encapsulate the logic. Additionally, an assertion has been added to detect negative viewInsets early, improving debuggability. A new regression test is also included to verify the fix. The changes are logical and well-implemented. My review includes a few suggestions to align the code with Effective Dart style guidelines.

Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

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

LGTM

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 15, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Dec 15, 2025
Merged via the queue into flutter:master with commit 34bb652 Dec 15, 2025
178 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android Web] resizeToAvoidBottomInset broken on Android. Keyboard breaks layout.

2 participants