-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[visionOS] Web process hangs under createDragImageFor{Link|Selection} when starting a drag for the first time #39867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
EWS run on previous version of this PR (hash d959b13) Details |
|
EWS run on previous version of this PR (hash 38dbd53) Details |
|
EWS run on previous version of this PR (hash 0405f3b) Details |
|
EWS run on current version of this PR (hash 6270ff4) Details |
|
(macOS failures are unrelated) |
|
Thanks for the review! |
… when starting a drag for the first time https://bugs.webkit.org/show_bug.cgi?id=286819 rdar://141448897 Reviewed by Abrar Rahman Protyasha. On visionOS, when starting a drag for the first time on a webpage, we end up spending a large amount of time underneath `+[UIScreen initialize]` within the web process, while trying to render the drag image using the helpers in `DragImageIOS.mm` (which instantiate `UIGraphicsImageRenderer`). This causes the web process to hang briefly, which in turn may cause the drag to fail entirely. To mitigate this, we refactor these helpers such that they no longer rely (indirectly) on instantiating `UIScreen` via `UIGraphicsImageRenderer`, and instead use `WebCore::ImageBuffer` and `sinkIntoNativeImage`. See below for more details. * Source/WebCore/dom/DataTransfer.cpp: (WebCore::DataTransfer::setDragImage): (WebCore::DataTransfer::updateDragImage): (WebCore::DataTransfer::createDragImage const): (WebCore::DragImageLoader::DragImageLoader): (WebCore::DragImageLoader::imageChanged): * Source/WebCore/dom/DataTransfer.h: * Source/WebCore/dom/DataTransferMac.mm: (WebCore::DataTransfer::createDragImage const): Plumb the `Document` through here, so that we can get the `deviceScaleFactor` / `HostWindow` and pass them through to `createDragImageFromImage`. * Source/WebCore/page/DragController.cpp: (WebCore::DragController::startDrag): (WebCore::DragController::doImageDrag): Pass the device scale factor and host window into `createDragImageFromImage`. * Source/WebCore/platform/DragImage.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/DragImage.h: * Source/WebCore/platform/cocoa/DragImageCocoa.mm: (WebCore::createDragImageFromImage): * Source/WebCore/platform/gtk/DragImageGtk.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/ios/DragImageIOS.mm: (WebCore::scaleDragImage): Make this helper function a no-op. This logic was actually unnecessary from the start, since the drag image will always perform lift and cancel animations using targeted previews which scale to fit the bounds of the dragged element. As such, there's no need to artificially clamp the drag image to an arbitrary maximum size of 400x400. (WebCore::createDragImageFromImage): Make this take both a device scale factor and `HostWindow`, which allows us to create a new `ImageBuffer`, paint the given image into the buffer (scaling down if needed), and finally extract a native image from the image buffer. This avoids the need for `UIGraphicsImageRenderer` entirely. (WebCore::deleteDragImage): (WebCore::cgImageFromTextIndicator): (WebCore::createDragImageForLink): Remove logic for creating a drag image representing a link (URL) platter. This has been unnecessary ever since we (1) adopted `+[UIDragPreview previewForURL:title:]`, and (2) use text indicator for the lift preview. Instead, just return the content image of the text indicator here. (WebCore::createDragImageForSelection): Adjust these helper methods, so that they simply return the content image of the text indicator. Note that we just use the text indicator itself for the targeted preview anyways, so this image is effectively unused. In a future patch, we should refactor `DragController` to not bail if the drag image's `image` is `nullptr` (but the `DragImage` is instead backed by a `TextIndicator`), which would allow us to avoid some of this extra work. (WebCore::cascadeForSystemFont): Deleted. * Source/WebCore/platform/win/DragImageWin.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/win/cairo/DragImageWinCairo.cpp: (WebCore::createDragImageFromImage): Canonical link: https://commits.webkit.org/289740@main
6270ff4 to
75ce30b
Compare
|
Committed 289740@main (75ce30b): https://commits.webkit.org/289740@main Reviewed commits have been landed. Closing PR #39867 and removing active labels. |
75ce30b
[visionOS] Web process hangs under createDragImageFor{Link|Selection} when starting a drag for the first time https://bugs.webkit.org/show_bug.cgi?id=286819 rdar://141448897 Reviewed by Abrar Rahman Protyasha. On visionOS, when starting a drag for the first time on a webpage, we end up spending a large amount of time underneath `+[UIScreen initialize]` within the web process, while trying to render the drag image using the helpers in `DragImageIOS.mm` (which instantiate `UIGraphicsImageRenderer`). This causes the web process to hang briefly, which in turn may cause the drag to fail entirely. To mitigate this, we refactor these helpers such that they no longer rely (indirectly) on instantiating `UIScreen` via `UIGraphicsImageRenderer`, and instead use `WebCore::ImageBuffer` and `sinkIntoNativeImage`. See below for more details. * Source/WebCore/dom/DataTransfer.cpp: (WebCore::DataTransfer::setDragImage): (WebCore::DataTransfer::updateDragImage): (WebCore::DataTransfer::createDragImage const): (WebCore::DragImageLoader::DragImageLoader): (WebCore::DragImageLoader::imageChanged): * Source/WebCore/dom/DataTransfer.h: * Source/WebCore/dom/DataTransferMac.mm: (WebCore::DataTransfer::createDragImage const): Plumb the `Document` through here, so that we can get the `deviceScaleFactor` / `HostWindow` and pass them through to `createDragImageFromImage`. * Source/WebCore/page/DragController.cpp: (WebCore::DragController::startDrag): (WebCore::DragController::doImageDrag): Pass the device scale factor and host window into `createDragImageFromImage`. * Source/WebCore/platform/DragImage.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/DragImage.h: * Source/WebCore/platform/cocoa/DragImageCocoa.mm: (WebCore::createDragImageFromImage): * Source/WebCore/platform/gtk/DragImageGtk.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/ios/DragImageIOS.mm: (WebCore::scaleDragImage): Make this helper function a no-op. This logic was actually unnecessary from the start, since the drag image will always perform lift and cancel animations using targeted previews which scale to fit the bounds of the dragged element. As such, there's no need to artificially clamp the drag image to an arbitrary maximum size of 400x400. (WebCore::createDragImageFromImage): Make this take both a device scale factor and `HostWindow`, which allows us to create a new `ImageBuffer`, paint the given image into the buffer (scaling down if needed), and finally extract a native image from the image buffer. This avoids the need for `UIGraphicsImageRenderer` entirely. (WebCore::deleteDragImage): (WebCore::cgImageFromTextIndicator): (WebCore::createDragImageForLink): Remove logic for creating a drag image representing a link (URL) platter. This has been unnecessary ever since we (1) adopted `+[UIDragPreview previewForURL:title:]`, and (2) use text indicator for the lift preview. Instead, just return the content image of the text indicator here. (WebCore::createDragImageForSelection): Adjust these helper methods, so that they simply return the content image of the text indicator. Note that we just use the text indicator itself for the targeted preview anyways, so this image is effectively unused. In a future patch, we should refactor `DragController` to not bail if the drag image's `image` is `nullptr` (but the `DragImage` is instead backed by a `TextIndicator`), which would allow us to avoid some of this extra work. (WebCore::cascadeForSystemFont): Deleted. * Source/WebCore/platform/win/DragImageWin.cpp: (WebCore::createDragImageFromImage): * Source/WebCore/platform/win/cairo/DragImageWinCairo.cpp: (WebCore::createDragImageFromImage): Canonical link: https://commits.webkit.org/289740@main6270ff4