Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (228056 => 228057)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-05 02:18:45 UTC (rev 228057)
@@ -1,5 +1,23 @@
2018-02-04 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r227936. rdar://problem/37145449
+
+ 2018-01-31 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ BitmapImage::drawPattern() may not draw a complete frame even after all the data is received
+ https://bugs.webkit.org/show_bug.cgi?id=182277
+
+ Reviewed by Simon Fraser.
+
+ * http/tests/images/draw-pattern-slow-load-large-image-expected.html: Added.
+ * http/tests/images/draw-pattern-slow-load-large-image.html: Added.
+ * http/tests/resources/load-and-stall.php: Add a new argument to allow
+ repeating the stall till the end of the file. This simulates real slow
+ network where sending data and stalling happens constantly and not only
+ a single time.
+
+2018-02-04 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r227926. rdar://problem/37145475
2018-01-31 Ryosuke Niwa <rn...@webkit.org>
Added: branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image-expected.html (0 => 228057)
--- branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image-expected.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image-expected.html 2018-02-05 02:18:45 UTC (rev 228057)
@@ -0,0 +1,11 @@
+<style>
+ .box {
+ width: 300px;
+ height: 300px;
+ background-color: green;
+}
+</style>
+<body>
+ <h1>This test ensures drawPattern() decodes a new image frame when new encoded data is received.</h1>
+ <div class="box"></div>
+</body>
Added: branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image.html (0 => 228057)
--- branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/images/draw-pattern-slow-load-large-image.html 2018-02-05 02:18:45 UTC (rev 228057)
@@ -0,0 +1,53 @@
+<style>
+ .box {
+ width: 300px;
+ height: 300px;
+ background-color: red;
+ background-position: 50px 50px;
+ background-size: 50px 50px;
+ background-repeat: repeat;
+}
+</style>
+<body>
+ <h1>This test ensures drawPattern() decodes a new image frame when new encoded data is received.</h1>
+ <div class="box"></div>
+ <script>
+ // The maximum buffering interval for ImageResource is 500ms. Choose stallFor
+ // such that the image buffering is disabled in the network process.
+ function slowLargeImageSourceURL() {
+ return "http://127.0.0.1:8000/resources/load-and-stall.php"
+ + "?name=../../../fast/images/resources/green-400x400.png"
+ + "&mimeType=image%2Fpng"
+ + "&stallAt=512"
+ + "&stallFor=0.6"
+ + "&stallRepeat=True";
+ }
+
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ var image = new Image;
+ var box = document.querySelector(".box");
+
+ image.src = ""
+
+ // Disable the CachedImage buffering as well. This has to happen after setting
+ // the src to make sure the Image element has created its CachedImage
+ if (window.internals)
+ internals.setForceUpdateImageDataEnabledForTesting(image, true);
+
+ box.style.backgroundImage = "url(" + image.src + ")";
+
+ var interval = setInterval(function() {
+ if (image.complete) {
+ clearInterval(interval);
+ testRunner.notifyDone();
+ }
+ else if (window.testRunner) {
+ // Force layout and drawing eveny 100ms.
+ document.body.offsetHeight;
+ testRunner.display();
+ }
+ }, 100);
+ </script>
+</body>
Modified: branches/safari-605-branch/LayoutTests/http/tests/resources/load-and-stall.php (228056 => 228057)
--- branches/safari-605-branch/LayoutTests/http/tests/resources/load-and-stall.php 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/LayoutTests/http/tests/resources/load-and-stall.php 2018-02-05 02:18:45 UTC (rev 228057)
@@ -2,6 +2,7 @@
$name = $_GET['name'];
$stallAt = $_GET['stallAt'];
$stallFor = $_GET['stallFor'];
+$stallRepeat = $_GET['stallRepeat'];
$mimeType = $_GET['mimeType'];
$file = fopen($name, "rb");
@@ -13,26 +14,37 @@
if (isset($stallAt) && isset($stallFor)) {
$stallAt = (int)$stallAt;
- $stallFor = (int)$stallFor;
if ($stallAt > filesize($name))
die("Incorrect value for stallAt.");
- $written = 0;
- while ($written < $stallAt) {
- $write = 1024;
- if ($write > $stallAt - $written)
- $write = $stallAt - $written;
- echo(fread($file, $write));
- $written += $write;
- flush();
- ob_flush();
+ $writtenTotal = 0;
+ $fileSize = filesize($name);
+
+ while ($writtenTotal < $fileSize) {
+ $stallAt = min($stallAt, $fileSize - $writtenTotal);
+ $written = 0;
+
+ while ($written < $stallAt) {
+ $write = min(1024, $stallAt - $written);
+ echo(fread($file, $write));
+ $written += $write;
+ flush();
+ ob_flush();
+ }
+
+ $writtenTotal += $written;
+ $remaining = $fileSize - $writtenTotal;
+ if (!$remaining)
+ break;
+
+ usleep($stallFor * 1000000);
+ if (!isset($stallRepeat) || !$stallRepeat)
+ $stallAt = $remaining;
}
- usleep($stallFor * 1000000);
- echo(fread($file, filesize($name) - $stallAt));
} else {
echo(fread($file, filesize($name)));
+ flush();
+ ob_flush();
}
-flush();
-ob_flush();
fclose($file);
?>
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-05 02:18:45 UTC (rev 228057)
@@ -1,5 +1,36 @@
2018-02-04 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r227936. rdar://problem/37145449
+
+ 2018-01-31 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ BitmapImage::drawPattern() may not draw a complete frame even after all the data is received
+ https://bugs.webkit.org/show_bug.cgi?id=182277
+
+ Reviewed by Simon Fraser.
+
+ BitmapImage::drawPattern() needs to destroy the incomplete decoded frame
+ before trying to draw it as a pattern.
+
+ Test: http/tests/images/draw-pattern-slow-load-large-image.html
+
+ * loader/cache/CachedImage.cpp:
+ (WebCore::CachedImage::updateBufferInternal): We need to disable CachedImage
+ data buffering for testing. This simulates slow network where intervals
+ between data chunks can last for seconds.
+ * loader/cache/CachedImage.h:
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::drawPattern): Destroy the incomplete decoded frame
+ before drawing this frame as a pattern. We do not destroy incomplete decoded
+ frame once new data is received because it may be drawn by async image
+ drawing while waiting for the newer frame to finish decoding.
+ * testing/Internals.cpp:
+ (WebCore::Internals::setForceUpdateImageDataEnabledForTesting):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+2018-02-04 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r227934. rdar://problem/37145534
2018-01-31 Ryosuke Niwa <rn...@webkit.org>
Modified: branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.cpp (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.cpp 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.cpp 2018-02-05 02:18:45 UTC (rev 228057)
@@ -431,7 +431,7 @@
// Don't update the image with the new buffer very often. Changing the decoder
// internal data and repainting the observers sometimes are very expensive operations.
- if (shouldDeferUpdateImageData())
+ if (!m_forceUpdateImageDataEnabledForTesting && shouldDeferUpdateImageData())
return;
EncodedDataStatus encodedDataStatus = EncodedDataStatus::Unknown;
Modified: branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.h (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.h 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/loader/cache/CachedImage.h 2018-02-05 02:18:45 UTC (rev 228057)
@@ -87,6 +87,8 @@
void addPendingImageDrawingClient(CachedImageClient&);
+ void setForceUpdateImageDataEnabledForTesting(bool enabled) { m_forceUpdateImageDataEnabledForTesting = enabled; }
+
private:
void clear();
@@ -178,6 +180,7 @@
std::unique_ptr<SVGImageCache> m_svgImageCache;
bool m_isManuallyCached { false };
bool m_shouldPaintBrokenImage { true };
+ bool m_forceUpdateImageDataEnabledForTesting { false };
};
} // namespace WebCore
Modified: branches/safari-605-branch/Source/WebCore/platform/graphics/BitmapImage.cpp (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/platform/graphics/BitmapImage.cpp 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/platform/graphics/BitmapImage.cpp 2018-02-05 02:18:45 UTC (rev 228057)
@@ -291,7 +291,12 @@
return;
if (!ctxt.drawLuminanceMask()) {
+ // If new data is received, the current incomplete decoded frame has to be destroyed.
+ if (m_currentFrameDecodingStatus == DecodingStatus::Invalid)
+ m_source->destroyIncompleteDecodedData();
+
Image::drawPattern(ctxt, destRect, tileRect, transform, phase, spacing, op, blendMode);
+ m_currentFrameDecodingStatus = frameDecodingStatusAtIndex(m_currentFrame);
return;
}
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.cpp (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-02-05 02:18:45 UTC (rev 228057)
@@ -836,6 +836,12 @@
if (auto* bitmapImage = bitmapImageFromImageElement(element))
bitmapImage->setLargeImageAsyncDecodingEnabledForTesting(enabled);
}
+
+void Internals::setForceUpdateImageDataEnabledForTesting(HTMLImageElement& element, bool enabled)
+{
+ if (auto* cachedImage = element.cachedImage())
+ cachedImage->setForceUpdateImageDataEnabledForTesting(enabled);
+}
void Internals::setGridMaxTracksLimit(unsigned maxTrackLimit)
{
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.h (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.h 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.h 2018-02-05 02:18:45 UTC (rev 228057)
@@ -141,6 +141,7 @@
unsigned imageDecodeCount(HTMLImageElement&);
unsigned pdfDocumentCachingCount(HTMLImageElement&);
void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled);
+ void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled);
void setGridMaxTracksLimit(unsigned);
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.idl (228056 => 228057)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.idl 2018-02-05 02:18:42 UTC (rev 228056)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.idl 2018-02-05 02:18:45 UTC (rev 228057)
@@ -264,6 +264,7 @@
unsigned long imageDecodeCount(HTMLImageElement element);
unsigned long pdfDocumentCachingCount(HTMLImageElement element);
void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement element, boolean enabled);
+ void setForceUpdateImageDataEnabledForTesting(HTMLImageElement element, boolean enabled);
void setGridMaxTracksLimit(unsigned long maxTracksLimit);