Diff
Modified: trunk/LayoutTests/ChangeLog (194325 => 194326)
--- trunk/LayoutTests/ChangeLog 2015-12-21 02:54:32 UTC (rev 194325)
+++ trunk/LayoutTests/ChangeLog 2015-12-21 04:23:09 UTC (rev 194326)
@@ -1,3 +1,18 @@
+2015-12-20 Jeremy Zerfas <[email protected]>
+
+ Don't allocate a NSImage and skip unneeded call to TIFFRepresentation when copying image to clipboard.
+ https://bugs.webkit.org/show_bug.cgi?id=152374
+
+ Reviewed by Darin Adler.
+
+ Added test to make sure that when copying a 50 frame 500x500 animation
+ (50 MB uncompressed) to the clipboard, the additional memory usage is
+ kept to less than 200 MB.
+
+ * fast/images/image-copy-memory-usage-expected.txt: Added.
+ * fast/images/image-copy-memory-usage.html: Added.
+ * fast/images/resources/dot-moving-in-a-circle-animation.gif: Added.
+
2015-12-20 Commit Queue <[email protected]>
Unreviewed, rolling out r194033 and r194267.
Added: trunk/LayoutTests/fast/images/image-copy-memory-usage-expected.txt (0 => 194326)
--- trunk/LayoutTests/fast/images/image-copy-memory-usage-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/images/image-copy-memory-usage-expected.txt 2015-12-21 04:23:09 UTC (rev 194326)
@@ -0,0 +1,14 @@
+This is an automated test related to Bug 152374 - Reduce resource usage when copying image to clipboard.
+
+This tests how much memory is used while copying an animation into the clipboard. The animation consists of 50 500x500 frames and, assuming 32 bits per pixel, will use 50 MB of memory when uncompressed. To pass the test, after copying the animation to the clipboard, the memory usage of the browser must not have increased by more than 200 MBs.
+
+In order to make this test more accurate it should be performed in a freshly started browser session that has nothing else open and which has an empty cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS changeInCommittedVMBytes < 200000000 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/images/image-copy-memory-usage.html (0 => 194326)
--- trunk/LayoutTests/fast/images/image-copy-memory-usage.html (rev 0)
+++ trunk/LayoutTests/fast/images/image-copy-memory-usage.html 2015-12-21 04:23:09 UTC (rev 194326)
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8" />
+ <title>image-copy-memory-usage.html</title>
+ <script src=""
+ </head>
+
+ <body>
+ <script type="text/_javascript_">
+ description("This is an automated test related to " +
+ "<a href="" 152374 - Reduce resource usage when " +
+ "copying image to clipboard</a>.<br />" +
+ "<br />" +
+ "This tests how much memory is used while copying an animation into the clipboard. The animation " +
+ "consists of 50 500x500 frames and, assuming 32 bits per pixel, will use 50 MB of memory when " +
+ "uncompressed. To pass the test, after copying the animation to the clipboard, the memory usage of " +
+ "the browser must not have increased by more than 200 MBs.<br />" +
+ "<br />" +
+ "In order to make this test more accurate it should be performed in a freshly started browser " +
+ "session that has nothing else open and which has an empty cache.");
+
+ window.jsTestIsAsync = true;
+
+ var changeInCommittedVMBytes; // Needs to be global for shouldBeTrue() to see it.
+
+ function tryToSetUpAndRunTest()
+ {
+ // Exit if the mallocStatistics() function is not available since it is needed to automatically
+ // determine the results of the test.
+ if (!window.internals || !window.internals.mallocStatistics) {
+ debug("The mallocStatistics() function is not available, you will need to check memory usage " +
+ "manually. First record the memory usage of the browser. Then copy the animation into the " +
+ "clipboard. Finally check the memory usage of the browser again and subtract the amount of " +
+ "memory that it was using previously. If the difference is greater than 200 MBs, the browser " +
+ "has failed the test.<br />");
+ return;
+ }
+
+ var initialCommittedVMBytes = window.internals.mallocStatistics().committedVMBytes;
+ // Add a listener for clipboard copy events which will then check how much memory was used to perform
+ // the copy and also finish the test. setTimeout() is used with a zero delay in order to cause this to
+ // run after the copy is finished.
+ document.getElementById("animationFrame").contentWindow.document.addEventListener("copy",
+ setTimeout(
+ function()
+ {
+ var finalCommittedVMBytes = window.internals.mallocStatistics().committedVMBytes;
+ changeInCommittedVMBytes = finalCommittedVMBytes - initialCommittedVMBytes;
+ shouldBeTrue("changeInCommittedVMBytes < 200000000");
+ window.finishJSTest();
+ },
+ 0),
+ false);
+
+ // Exit if execCommand("copy") is not supported since that is needed to automatically copy the animation
+ // to the clipboard.
+ if (!document.queryCommandSupported('copy')) {
+ debug("execCommand(\"copy\") is not supported. You will need to manually copy the animation into " +
+ "the clipboard to finish the test.<br />");
+ return;
+ }
+
+ document.getElementById("animationFrame").contentWindow.document.execCommand("copy");
+ }
+ </script>
+
+ <!-- The "Copy Image" option doesn't show up in the image context menu if using a data URI and that might make
+ - it difficult to perform a copy manually so load the image from a file instead.
+ -->
+ <iframe id="animationFrame" width="500" height="500" _onload_="tryToSetUpAndRunTest()"
+ src=""
+ </iframe>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/images/resources/dot-moving-in-a-circle-animation.gif (0 => 194326)
--- trunk/LayoutTests/fast/images/resources/dot-moving-in-a-circle-animation.gif (rev 0)
+++ trunk/LayoutTests/fast/images/resources/dot-moving-in-a-circle-animation.gif 2015-12-21 04:23:09 UTC (rev 194326)
@@ -0,0 +1,28 @@
+GIF89a\xF4\xF4\xF1\xE6\xE6\xE6!\xFFNETSCAPE2.0!\xF9\xFF,\xF4\xF4@\xFF\x8C\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3 \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\xA8\xA0\x80\xD8\xE8H\xB6\xB8\xF88IYiy\x89\x99\xA9\xB9\xC9\xD9\xE9\xF9 *:JZjz\x8A\x9A\xAA\xBA\xCA\xDA\xEA\xFA
++;K[k{\x8B\x9B\xAB\xBB\xCB\xDB\xEB\xFB,<L\l|\x8C\x9C\xAC\xBC\xCC\xDC\xEC\xFC-=M]m}\x8D\x9D\xAD\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xA0\x9FZ\x83PJ\xED\xC5Fo\xEEM\xDC:#\xA9\x9DG\xAA\xAEb\xC7\xF2L\xD7\xF6\xAD!\xF9,\xBC\x90#\x8C\x8F\xC0\xA0\x9FZ\x83PJ\xED\xC5Fo\xEEM\xDC:#\xA9\x9DG\xAA\xAEb\xC7\xF2LZ!\xF9,\xC9\x8C!\x8C\x8Fi\xC0\xA0\xAFZ\x83TJ\xED\xC5Gox\x8AYjhg\xAD\xC8\xE7\xC6\xF2L+!\xF9,\xD7\x89+!\x8C\x8Fy\x
C0\xA0\xFFZ\x834HYսm\xDC\xDFZ\xA3S\x9A[\xBApl˼\xF2L#;
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (194325 => 194326)
--- trunk/Source/WebCore/ChangeLog 2015-12-21 02:54:32 UTC (rev 194325)
+++ trunk/Source/WebCore/ChangeLog 2015-12-21 04:23:09 UTC (rev 194326)
@@ -1,3 +1,21 @@
+2015-12-20 Jeremy Zerfas <[email protected]>
+
+ Don't allocate a NSImage and skip unneeded call to TIFFRepresentation when copying image to clipboard.
+ https://bugs.webkit.org/show_bug.cgi?id=152374
+
+ Reviewed by Darin Adler.
+
+ When copying an image to the clipboard, don't bother allocating a
+ NSImage and skip the unneeded call to TIFFRepresentation since the data
+ from the previous getTIFFRepresentation call can be used instead. This
+ considerably reduces the amount of memory and CPU time used for large
+ images/animations.
+
+ Test: fast/images/image-copy-memory-usage.html
+
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::write):
+
2015-12-20 Gyuyoung Kim <[email protected]>
Reduce PassRefPtr uses in dom - 2
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (194325 => 194326)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2015-12-21 02:54:32 UTC (rev 194325)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2015-12-21 04:23:09 UTC (rev 194326)
@@ -255,7 +255,7 @@
void Pasteboard::write(const PasteboardImage& pasteboardImage)
{
- NSData *imageData = [pasteboardImage.image->getNSImage() TIFFRepresentation];
+ CFDataRef imageData = pasteboardImage.image->getTIFFRepresentation();
if (!imageData)
return;
@@ -263,7 +263,7 @@
ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(pasteboardImage.resourceMIMEType));
m_changeCount = writeURLForTypes(writableTypesForImage(), m_pasteboardName, pasteboardImage.url);
- m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(imageData), NSTIFFPboardType, m_pasteboardName);
+ m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapCFData(imageData), NSTIFFPboardType, m_pasteboardName);
writeFileWrapperAsRTFDAttachment(fileWrapper(pasteboardImage), m_pasteboardName, m_changeCount);
}