<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202532] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202532">202532</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-06-27 18:44:41 -0700 (Mon, 27 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
https://bugs.webkit.org/show_bug.cgi?id=159077

Reviewed by Tim Horton.

Source/WebKit2:

Fix WebPageProxy::forceRepaint() to correctly wait for the next commit from the web process,
which is necessary for UI-side compositing.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::forceRepaint):

Tools:

Re-enable render server snapshotting for iOS WTR via the change in InjectedBundlePage.cpp.

Fix WebPageProxy::forceRepaint() to correctly wait for the next commit from the web process,
which is necessary for UI-side compositing.

Add some null checks to fix issues when the WKWebView gets resized to be empty, which
seems to happen for some tests that call window.resizeTo().

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::dump): Deleted.
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::dumpResults):
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::createCGContextFromImage):
(WTR::computeMD5HashStringForContext):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::windowSnapshotImage):

LayoutTests:

fast/harness/snapshot-captures-compositing.html passes now.

* platform/ios-simulator-wk2/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationcpp">trunk/Tools/WebKitTestRunner/TestInvocation.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnercgTestInvocationCGcpp">trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosPlatformWebViewIOSmm">trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/LayoutTests/ChangeLog        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-06-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        fast/harness/snapshot-captures-compositing.html passes now.
+
+        * platform/ios-simulator-wk2/TestExpectations:
+
</ins><span class="cx"> 2016-06-27  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Adopt the iOS TouchEventHandler API for cases that must have synchronous dispatch
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -1899,5 +1899,3 @@
</span><span class="cx"> webkit.org/b/157589 fast/text-autosizing/ios/text-autosizing-after-back.html [ Pass Timeout ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/157990 [ Release ] mathml/wbr-in-mroot-crash.html [ Pass Timeout ]
</span><del>-
-webkit.org/b/159077 fast/harness/snapshot-captures-compositing.html [ ImageOnlyFailure ]
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-06-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        Fix WebPageProxy::forceRepaint() to correctly wait for the next commit from the web process,
+        which is necessary for UI-side compositing.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::forceRepaint):
+
</ins><span class="cx"> 2016-06-27  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: When modifying sessionStorage, localStorage gets updated
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -2888,8 +2888,18 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    uint64_t callbackID = callback-&gt;callbackID();
-    m_callbacks.put(callback);
</del><ins>+    std::function&lt;void (CallbackBase::Error)&gt; didForceRepaintCallback = [this, callback](CallbackBase::Error error) {
+        callAfterNextPresentationUpdate([callback](CallbackBase::Error error) {
+            if (error != CallbackBase::Error::None) {
+                callback-&gt;invalidate(error);
+                return;
+            }
+
+            callback-&gt;performCallback();
+        });
+    };
+
+    uint64_t callbackID = m_callbacks.put(didForceRepaintCallback, m_process-&gt;throttler().backgroundActivityToken());
</ins><span class="cx">     m_drawingArea-&gt;waitForBackingStoreUpdateOnNextPaint();
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::ForceRepaint(callbackID), m_pageID); 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Tools/ChangeLog        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-06-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS] Make DumpRenderTree and WebKitTestRunner in the simulator use render server snapshotting
+        https://bugs.webkit.org/show_bug.cgi?id=159077
+
+        Reviewed by Tim Horton.
+
+        Re-enable render server snapshotting for iOS WTR via the change in InjectedBundlePage.cpp.
+
+        Fix WebPageProxy::forceRepaint() to correctly wait for the next commit from the web process,
+        which is necessary for UI-side compositing.
+
+        Add some null checks to fix issues when the WKWebView gets resized to be empty, which
+        seems to happen for some tests that call window.resizeTo().
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::dump): Deleted.
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::dumpResults):
+        * WebKitTestRunner/cg/TestInvocationCG.cpp:
+        (WTR::createCGContextFromImage):
+        (WTR::computeMD5HashStringForContext):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::windowSnapshotImage):
+
</ins><span class="cx"> 2016-06-27  Gyuyoung Kim  &lt;gyuyoung.kim@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Support to build on Debian linux
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -895,12 +895,7 @@
</span><span class="cx">         injectedBundle.dumpBackForwardListsForAllPages(stringBuilder);
</span><span class="cx"> 
</span><span class="cx">     if (injectedBundle.shouldDumpPixels() &amp;&amp; injectedBundle.testRunner()-&gt;shouldDumpPixels()) {
</span><del>-#if PLATFORM(IOS)
-        // PlatformWebView::windowSnapshotImage() has timing problems, so use WebProcess snapshots for now.
-        bool shouldCreateSnapshot = true;
-#else
</del><span class="cx">         bool shouldCreateSnapshot = injectedBundle.testRunner()-&gt;isPrinting();
</span><del>-#endif
</del><span class="cx">         if (shouldCreateSnapshot) {
</span><span class="cx">             WKSnapshotOptions options = kWKSnapshotOptionsShareable;
</span><span class="cx">             WKRect snapshotRect = WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -248,8 +248,8 @@
</span><span class="cx">                 m_webProcessIsUnresponsive = true;
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><ins>+
</ins><span class="cx">             WKRetainPtr&lt;WKImageRef&gt; windowSnapshot = TestController::singleton().mainWebView()-&gt;windowSnapshotImage();
</span><del>-            ASSERT(windowSnapshot);
</del><span class="cx">             dumpPixelsAndCompareWithExpected(windowSnapshot.get(), m_repaintRects.get(), TestInvocation::SnapshotResultType::WebView);
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercgTestInvocationCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -57,15 +57,19 @@
</span><span class="cx">     // Creating this bitmap in the device color space should prevent any color conversion when the image of the web view is drawn into it.
</span><span class="cx">     RetainPtr&lt;CGColorSpaceRef&gt; colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
</span><span class="cx">     CGContextRef context = CGBitmapContextCreate(0, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
</span><ins>+    if (!context)
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    
</del><span class="cx">     CGContextDrawImage(context, CGRectMake(0, 0, pixelsWide, pixelsHigh), image.get());
</span><del>-
</del><span class="cx">     return context;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[33])
</span><span class="cx"> {
</span><ins>+    if (!bitmapContext) {
+        WTFLogAlways(&quot;computeMD5HashStringForContext: context is null\n&quot;);
+        return;
+    }
</ins><span class="cx">     ASSERT(CGBitmapContextGetBitsPerPixel(bitmapContext) == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
</span><span class="cx">     size_t pixelsHigh = CGBitmapContextGetHeight(bitmapContext);
</span><span class="cx">     size_t pixelsWide = CGBitmapContextGetWidth(bitmapContext);
</span><span class="lines">@@ -144,7 +148,16 @@
</span><span class="cx"> 
</span><span class="cx"> void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects, SnapshotResultType snapshotType)
</span><span class="cx"> {
</span><ins>+    if (!image) {
+        WTFLogAlways(&quot;dumpPixelsAndCompareWithExpected: image is null\n&quot;);
+        return;
+    }
+
</ins><span class="cx">     RetainPtr&lt;CGContextRef&gt; context = adoptCF(createCGContextFromImage(image));
</span><ins>+    if (!context) {
+        WTFLogAlways(&quot;dumpPixelsAndCompareWithExpected: context is null\n&quot;);
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     // A non-null repaintRects array means we're doing a repaint test.
</span><span class="cx">     if (repaintRects)
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosPlatformWebViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (202531 => 202532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm        2016-06-28 01:13:53 UTC (rev 202531)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm        2016-06-28 01:44:41 UTC (rev 202532)
</span><span class="lines">@@ -212,6 +212,10 @@
</span><span class="cx">     CGSize viewSize = m_view.bounds.size;
</span><span class="cx">     int bufferWidth = ceil(viewSize.width * deviceScaleFactor);
</span><span class="cx">     int bufferHeight = ceil(viewSize.height * deviceScaleFactor);
</span><ins>+    if (!bufferWidth || !bufferHeight) {
+        WTFLogAlways(&quot;Being asked for snapshot of view with width %d height %d\n&quot;, bufferWidth, bufferHeight);
+        return nullptr;
+    }
</ins><span class="cx"> 
</span><span class="cx">     CARenderServerBufferRef buffer = CARenderServerCreateBuffer(bufferWidth, bufferHeight);
</span><span class="cx">     if (!buffer) {
</span></span></pre>
</div>
</div>

</body>
</html>