|
| 1 | +2017-07-17 Wenson Hsieh < [email protected]> |
| 2 | + |
| 3 | + [iOS DnD] Web process uses too much memory when beginning a drag on a very large image |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=174585 |
| 5 | + <rdar://problem/33302541> |
| 6 | + |
| 7 | + Reviewed by Tim Horton. |
| 8 | + |
| 9 | + Currently, attempting to drag a very large image fails, either due to us telling CoreGraphics to create an image |
| 10 | + buffer that is too large, or because the web process exceeds its memory limit and gets jetsamed. There are two |
| 11 | + places where we can optimize our memory use during the drag initialization sequence, and this patch improves |
| 12 | + both. |
| 13 | + |
| 14 | + First, on iOS, we attempt to encode and send over a WebCore::Image in the PasteboardImage when writing to the |
| 15 | + item providers upon starting a drag. Currently, this Image is only used in the drag and drop codepath, in |
| 16 | + PlatformPasteboard::writeObjectRepresentations, to grab the size of the image being written for the purpose of |
| 17 | + specifying estimated display size. Serializing and deserializing an Image calls into Image::nativeImage, which |
| 18 | + attempts to draw the contents of the image into a buffer so that it can be shipped across to the UI process. |
| 19 | + Instead, we can simply compute the size in the web process while we already have the Image, and simply send that |
| 20 | + across. For copy/paste, this doesn't result in any behavior change, since we don't use the PasteboardImage's |
| 21 | + image in the first place. |
| 22 | + |
| 23 | + Secondly, when starting a drag, we try to allocate create an image buffer the size of the WebCore::Image for the |
| 24 | + purpose of generating the drag preview. Instead, this patch establishes a limit on the size of this drag preview |
| 25 | + image, such that if the Image's size is larger, we'll scale down the drag preview image to be the maximum |
| 26 | + allowed size. |
| 27 | + |
| 28 | + Test: DataInteractionTests.CanStartDragOnEnormousImage. |
| 29 | + |
| 30 | + * editing/ios/EditorIOS.mm: |
| 31 | + (WebCore::Editor::writeImageToPasteboard): |
| 32 | + * platform/Pasteboard.h: |
| 33 | + * platform/graphics/GeometryUtilities.cpp: |
| 34 | + (WebCore::sizeWithAreaAndAspectRatio): |
| 35 | + |
| 36 | + Introduce a new helper function to compute a size with the given aspect ratio and area. |
| 37 | + |
| 38 | + * platform/graphics/GeometryUtilities.h: |
| 39 | + * platform/ios/DragImageIOS.mm: |
| 40 | + (WebCore::createDragImageFromImage): |
| 41 | + * platform/ios/PlatformPasteboardIOS.mm: |
| 42 | + (WebCore::PlatformPasteboard::writeObjectRepresentations): |
| 43 | + |
1 | 44 | 2017-07-17 Michael Catanzaro < [email protected]>
|
2 | 45 |
|
3 | 46 | [CMake] Include most CMake modules from WebKitCommon.cmake
|
|
0 commit comments