Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6269463a4c4fef31834c398cc93b9d7f08605fdb
https://github.com/WebKit/WebKit/commit/6269463a4c4fef31834c398cc93b9d7f08605fdb
Author: Wenson Hsieh <[email protected]>
Date: 2025-12-15 (Mon, 15 Dec 2025)
Changed paths:
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Log Message:
-----------
[iOS] Safari sometimes crashes under -[UIPreviewTarget
initWithContainer:center:transform:]
https://bugs.webkit.org/show_bug.cgi?id=304152
rdar://162978545
Reviewed by Abrar Rahman Protyasha.
This is a speculative fix for an ObjC exception when presenting a context menu
on iOS:
```
*** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason:
'UIPreviewTarget requires that the container view is in a window, but it is
not. (container:
<WKTargetedPreviewContainer: 0x6b8f29f80; name=Context Menu Hint Preview
Container>)
```
>From code inspection, it's theoretically possible for this context menu
>preview container to be
removed in the time between when:
•
`-contextMenuInteraction:configuration:highlightPreviewForItemWithIdentifier:`
is called, and when
• `-contextMenuInteraction:willDisplayMenuForConfiguration:animator:` is called
...although I was unable to reproduce this locally to confirm. While we already
have a mechanism to
avoid removing the context menu when `_isDisplayingContextMenuWithAnimation` is
set (i.e. between
when `willDisplayMenuForConfiguration:` is called and when the animator
completion block is called),
this doesn't extend to *before* `willDisplayMenuForConfiguration:` is called.
To fix this, we add a
new flag and guard removing the context menu hint container on this flag being
false.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setUpInteraction]):
(-[WKContentView containerForContextMenuHintPreviews]):
(-[WKContentView _removeContainerForContextMenuHintPreviews]):
Also add release logging, so that we can gather more data about the context
menu hint container
lifetime to diagnose further issues.
(-[WKContentView _removeContextMenuHintContainerIfPossible]):
Return early if `_isPreparingToDisplayContextMenu` is set; see above.
(-[WKContentView
contextMenuInteraction:configuration:highlightPreviewForItemWithIdentifier:]):
(-[WKContentView
contextMenuInteraction:willDisplayMenuForConfiguration:animator:]):
Canonical link: https://commits.webkit.org/304459@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications