Skip to content

[Super Editor][IME][Bug]: Fix zombie IME client when switching from one SuperEditor instance to a replacement SuperEditor instance (Resolve #2965)#2967

Merged
matthew-carroll merged 4 commits into
mainfrom
2965_super-editor-ime-re-open-conn-on-instance-change_main
Mar 8, 2026
Merged

[Super Editor][IME][Bug]: Fix zombie IME client when switching from one SuperEditor instance to a replacement SuperEditor instance (Resolve #2965)#2967
matthew-carroll merged 4 commits into
mainfrom
2965_super-editor-ime-re-open-conn-on-instance-change_main

Conversation

@matthew-carroll

@matthew-carroll matthew-carroll commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

[Super Editor][IME][Bug]: Fixed zombie IME client when switching from one SuperEditor instance to a replacement SuperEditor instance (Resolve #2965)

From the issue ticket:

  1. SuperEditor initializes
  2. SuperEditor creates its IME client and connects it to the OS via SharedIme
  3. The ancestor tree gets invalidated (a parent calling setState())
  4. SuperEditor 2 initializes
  5. SuperEditor 2 claims ownership over IME (but no connection is created because we're the same "role" and there's already a connection)
  6. SuperEditor 1 disposes (no impact on SharedIme because this instance is no longer the owner)

Problem: The existing IME connection, which survives across the widget instance change, it bound to the IME client for SuperEditor 1, which is different from the IME client for SuperEditor 2. As a result, IME input keeps flowing to the defunct IME client, which belongs to the now disposed SuperEditor 1. This means the keyboard stays up, the user is typing, suggested input continues to display at the top of the keyboard, and yet nothing changes in the editor.

This problem is the result of me originally thinking that we could re-use the connection. I missed the fact that when claiming the SharedIme, and passing the client, we need to create an entirely new connection for the client, even if a connection is already open. There is no option in Flutter's API to replace one client with another, within the same connection.

One wrinkle to also remember here is that, I believe, when we open a new connection, we must tell the keyboard to show() if we want it to stay up. By default, if we don't do that, creating a new connection causes the keyboard to close.

@matthew-carroll matthew-carroll changed the title [Super Editor][IME][Bug]: Fixed zombie IME client when switching from one SuperEditor instance to a replacement SuperEditor instance (Resolve #2965) [Super Editor][IME][Bug]: Fix zombie IME client when switching from one SuperEditor instance to a replacement SuperEditor instance (Resolve #2965) Mar 8, 2026
@matthew-carroll matthew-carroll merged commit 29fadcd into main Mar 8, 2026
23 checks passed
@matthew-carroll matthew-carroll deleted the 2965_super-editor-ime-re-open-conn-on-instance-change_main branch March 8, 2026 01:15
github-actions Bot pushed a commit that referenced this pull request Mar 8, 2026
…ne SuperEditor instance to a replacement SuperEditor instance (Resolve #2965) (#2967)
matthew-carroll added a commit that referenced this pull request Mar 8, 2026
…ne SuperEditor instance to a replacement SuperEditor instance (Resolve #2965) (#2967)
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.

[Super Editor][IME][Bug] - Wrong IME client when transitioning from one SuperEditor instance to another

1 participant