Skip to content

[iOS] viewInsets.bottom drops mid-rise and then re-rises slowly when a third-party keyboard briefly reports a smaller height while showing #196578

Open

Description

@ysjkof

Steps to reproduce

  1. On an iPhone, enable a third-party keyboard extension (seen with the Korean keyboard 한글키 from the App Store) and make it the active keyboard.
  2. In a Flutter app, tap a TextField so the keyboard shows. Any layout that follows MediaQuery.viewInsetsOf(context).bottom makes it visible (e.g. a Scaffold with resizeToAvoidBottomInset, a bottom sheet with Padding(viewInsets), a Dialog).
  3. Dismiss the keyboard and tap the field again; repeat.

Expected results

viewInsets.bottom rises monotonically with the keyboard and arrives with it.

Actual results

In about half of the taps, viewInsets.bottom rises, then drops by 47–122 pt (median 66 pt) about 110 ms after the tap, and then rises again on a slow ease-in-out curve. It arrives ~70–90 ms after the non-dropping case (median 505–525 ms vs 434 ms from the tap). The keyboard itself does not do this: it keeps following its original spring and arrives at ~458–466 ms, so content first moves down and then trails the keyboard by up to ~210 pt.

With the system Korean keyboard on the same device and build: 0 of 12 taps.

Measured on a real device (iPhone 17 iPhone18,3, iOS 27.2, 120 Hz, profile build) with an integration-test harness: 44 taps, 25 dropped. For each tap we logged, on the same clock (CLOCK_MONOTONIC_RAW, aligned to FrameTiming.vsyncStart): every keyboard notification, the engine's keyboard-inset decisions and output (updateViewportMetricsWithInset:, swizzled for measurement only), the system keyboard's position (UIRemoteKeyboardWindow > UIInputSetHostView presentation layer), and viewInsets.bottom per frame.

What happens (every dropped tap, and in none of the others)

  1. ~72 ms after the tap, UIKit posts WillChangeFrame + WillShow with begin frame CGRectZero and end frame (0, 532, 402, 342), duration 0.383 s, inside the keyboard's spring animation block (UIView.inheritedAnimationDuration = 0.383). Because begin.y (0) > end.y (532) is false, the manager records the animation as not showing, then starts a spring (k 555.03, c 47.12, m 1) toward 342 pt. Taps that don't drop end here.
  2. 110–152 ms after the tap, the keyboard extension reports a transient height: Did/Will ChangeFrame + Show with end frame (0, 733, 402, 141) — posted outside any animation block (inheritedAnimationDuration = 0). Direction is again "not showing" (532 > 733 is false) and the vsync client is alive, so the animation is treated as compounding and only the spring's toValue changes, 1026 → 423 px. The spring value is proportional to toValue - fromValue, so the reported inset immediately drops to ~141/342 of its value.
  3. 12–27 ms later the extension reports 342 pt again ((0, 733, …141) → (0, 532, …342)), also outside an animation block. Now 733 > 532 is true, the direction differs, so startKeyBoardAnimation restarts from the dropped current inset (50–97 pt). Since the call isn't inside the keyboard's animation block, animateWithDuration: produces a CABasicAnimation with the default ease-in-out curve (0.42, 0, 0.58, 1) instead of a CASpringAnimation, so the manager falls back to the presentation layer and starts slowly.

Engine-reported and Dart-observed drops matched on all 44 taps (same verdict, same magnitude). On taps without the transient, the engine inset tracks the keyboard closely (median difference ~2 pt at the frame's target time).

The same logic is on master (5aa30617), engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyboardInsetManager.swift: direction and compounding at lines 151–161, restart at 325, presentation-layer fallback at 407–408, spring setup at 444–456. Observed on 3.47.6 (FlutterKeyboardInsetManager.mm lines 77–88, 273–275, 374–379).

Possible directions (not verified)

  • Treat an empty begin frame (CGRectZero) on WillShow as a showing animation, so the direction check isn't inverted.
  • While a show animation is in flight, a frame change that is posted outside an animation block and is followed by a return to the previous height could be ignored or coalesced; at least, lowering toValue mid-show should not make the reported inset go down.
  • When restarting outside an animation block, reuse the previous spring parameters rather than the default UIView curve.

Related: #193343 (same area — a height change mid-animation followed by a hide yields a huge negative inset for one frame; different cause and symptom).

Code sample

Code sample

Any TextField in a Scaffold. The numbers above come from our app's integration-test harness; I haven't built a separate minimal app, but nothing app-specific is involved — the drop is in the engine's reported inset.

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Flutter 3.47.6 • channel stable • framework revision 5fc346839b (2026-09-30) • engine revision 692136cb65 • Dart 3.13.5

Activity

  1. added
    in triage
    on Nov 16, 2026
  2. suryaKommana2662 commented on Nov 16, 2026

    @suryaKommana2662
    Contributor

    @ysjkof Thanks for the report. Could you please provide a minimal reproducible example demonstrating this issue? Also, please verify whether the issue is still reproducible on Flutter 3.50.0 stable.

    If possible, could you also share a short video demonstrating the keyboard animation issue? These details would help us reproduce the behavior and investigate the issue further.

  3. added
    waiting for response
    and removed
    in triage
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for response

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo