Skip to content

[Web] Korean IME composing range assertion failure after window blur (Cmd+Tab) during composition #183078

Closed

Description

@tobedoit

Steps to reproduce

  1. Run a Flutter Web app with a TextField on Chrome (macOS)
  2. Switch to Korean IME and start typing (e.g., type "한")
  3. While the character is still composing (cursor is on the character, not yet committed), press Cmd+Tab to switch to another app
  4. Switch back to the Flutter Web app
  5. Press Backspace

Expected results

Backspace should delete the composed character normally.

Actual results

Backspace does not work. The following assertion error is thrown:

═══ EXCEPTION CAUGHT BY SERVICES LIBRARY ═══
Failed assertion: line 1155 pos 7: 'googValue.googcomposing.end <= googValue.text.length'

composingBase: 1, composingExtent: 2, text: 한

The composing range (1–2) exceeds text.length (1), causing an assertion failure. After this, Backspace and other key inputs stop working.

Root cause analysis

When the browser window loses focus (window.blur), a compositionend event fires. This removes the composing text from the DOM, but Flutter's internal composing range is not updated accordingly. This creates a mismatch in TextEditingValue:

  • text.length = 1 (the composed character was committed/shortened)
  • composingBase = 1, composingExtent = 2 (still referencing the old composing range)

When the user returns and presses a key, TextEditingValue.fromJSON() hits the assertion before any app-level code can intercept.

Workarounds attempted (all failed)

# Approach Result
1 addPostFrameCallback after _restoreFocus() to clear composing Too late, assertion already fired
2 AppLifecycleState.inactive to clear composing Web doesn't fire inactive (only hidden)
3 window.blur event listener via conditional import + composing cleanup No effect
4 activeElement.blur() to force IME commit + TextField key regeneration IME switches to English + still fails
5 Focus restore with 50ms delay + composing cleanup No effect

The core issue is that the assertion fires in the platform channel → TextEditingValue.fromJSON() path, before any app-level Dart code can intervene.

Key constraint

  • English input: no issue
  • Composing completed (cursor outside character): no issue
  • Only occurs when composing is active (cursor on the character being composed)

Environment

  • Flutter 3.10+ (stable)
  • Chrome on macOS
  • Korean IME (macOS default)
  • Reproducible with both CanvasKit and HTML renderer

Related issues

Activity

  1. added
    in triagePresently being triaged by the triage team
    platform-webWeb applications specifically
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 5, 2026
  2. mbcorona commented on Mar 5, 2026

    @mbcorona
    Member

    Hi @tobedoit , Thanks for the report and root-cause analysis.

    I was able to successfully reproduce this assertion failure using the following steps:

    1. Switch Mac keyboard to Korean (2-Set).
    2. Type g k s (forms "한") in the TextField without pressing Space/Enter (leave in composing state).
    3. Press Cmd+Tab to switch windows, then Cmd+Tab back to Chrome.
    4. Press Backspace and the assertion fires.

    Triage Findings:

    • Flutter: 3.41.2
    • OS: macOS 26.3
    • Browser: Chrome

    Routing to team-web to investigate the compositionend event sync issue.

  3. added
    fyi-webFor the attention of Web platform team
    and removed
    team-webOwned by Web platform team
    on Mar 5, 2026
  4. added
    P2Important issues not at the top of the work list
    on Mar 5, 2026
  5. self-assigned this
    on Oct 13, 2026
  6. added a commit that references this issue on Oct 14, 2026
    a4896ba
  7. github-actions commented on Oct 28, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Oct 28, 2026
  9. added a commit that references this issue on Oct 29, 2026
    77f1ba3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.platform-webWeb applications specificallyteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions