Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: eb95cba0c2421219846b4ef9f9a0fb440eca488d
https://github.com/WebKit/WebKit/commit/eb95cba0c2421219846b4ef9f9a0fb440eca488d
Author: Wenson Hsieh <[email protected]>
Date: 2026-04-23 (Thu, 23 Apr 2026)
Changed paths:
M Source/WebKit/UIProcess/ios/WKContentView.mm
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Log Message:
-----------
[iOS] chatgpt.com: text selection in chat entry field sometimes flickers or
disappears
https://bugs.webkit.org/show_bug.cgi?id=313014
rdar://174689058
Reviewed by Abrar Rahman Protyasha.
Implement a speculative fix for this bug, which I have not been able to
reproduce in either debug or
release builds. While attached to a build of Safari in state, I was able to
determine that:
1. Initially, we correctly install the text selection interaction views in the
bottom fixed-
position container containing the chat box.
2. `-_updateChangedSelection:` is invoked as layer tree commits arrive, but
this doesn't call into
`-prepareToMoveSelectionContainer:` again because the editor state's
comparison result is
`EquivalentIncludingEnclosingLayer`.
3. At some point, the compositing view corresponding to that enclosing layer
is unparented, taking
the selection views out of the window along with it (this is what causes it
to disappear). In
this state, `-_selectionContainerViewInternal` returns `WKContentView`,
indicating that the
enclosing layer can no longer be found.
This seems to hint at some underlying issue where the computed `EditorState`'s
enclosing layer ID
isn't being correctly recomputed, but it's unclear how this is happening. To
mitigate this for now,
harden the UI-side logic to detect when the selection interaction views end up
in the wrong parent
view (or are unparented altogether), and fix it up in
`-prepareToMoveSelectionContainer:` (similar
to the case where the last sibling view changes).
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _didCommitLayerTree:mainFrameData:pageData:transactionID:]):
Additionally, invalidate the `_cachedSelectionContainerView` when the layer
tree commits. A stale
`_cachedSelectionContainerView` that points to an unparented view might also
explain the selection
being missing from the view hierarchy, though I was also not able to reproduce
this locally.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateChangedSelection:]):
(-[WKContentView _selectionContainerViewInternal]):
Canonical link: https://commits.webkit.org/311869@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications