Title: [249961] trunk
Revision
249961
Author
[email protected]
Date
2019-09-17 10:09:49 -0700 (Tue, 17 Sep 2019)

Log Message

REGRESSION (iOS 13): rAF stops firing when navigating away cross-origin and then back
https://bugs.webkit.org/show_bug.cgi?id=201767
<rdar://problem/55350854>

Reviewed by Geoffrey Garen.

Source/WebKit:

When navigating back and restoring a SuspendedPage, WebPage::reinitializeWebPage() ends up
reconstructing a new DrawingArea to match the identifier of the DrawingAreaProxy that the
UIProcess created. The issue is that when reconstructing the DrawingArea, we were losing
the DisplayRefreshMonitors that had been registered on the previous drawing area. To
address the issue, we now make sure to transfer the DisplayRefreshMonitors over from the
old to the new drawing area. This patch is kept as small as possible to faciliate cherry
picking to a branch. However, I think we should consider refactoring the code so that
we no longer need to re-create the DrawingArea in the WebProcess in this case.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::adoptDisplayRefreshMonitorsFromDrawingArea):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::adoptDisplayRefreshMonitorsFromDrawingArea):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::reinitializeWebPage):

LayoutTests:

Add layout test coverage.

* http/tests/navigation/page-cache-requestAnimationFrame-expected.txt: Added.
* http/tests/navigation/page-cache-requestAnimationFrame.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (249960 => 249961)


--- trunk/LayoutTests/ChangeLog	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/LayoutTests/ChangeLog	2019-09-17 17:09:49 UTC (rev 249961)
@@ -1,5 +1,18 @@
 2019-09-17  Chris Dumez  <[email protected]>
 
+        REGRESSION (iOS 13): rAF stops firing when navigating away cross-origin and then back
+        https://bugs.webkit.org/show_bug.cgi?id=201767
+        <rdar://problem/55350854>
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage.
+
+        * http/tests/navigation/page-cache-requestAnimationFrame-expected.txt: Added.
+        * http/tests/navigation/page-cache-requestAnimationFrame.html: Added.
+
+2019-09-17  Chris Dumez  <[email protected]>
+
         Unreviewed, address flakiness of imported/w3c/web-platform-tests/IndexedDB/fire-error-event-exception.html
 
         Do not log console messages.

Added: trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame-expected.txt (0 => 249961)


--- trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame-expected.txt	2019-09-17 17:09:49 UTC (rev 249961)
@@ -0,0 +1,14 @@
+Tests that requestAnimationFrame() does not break when restoring from PageCache upon navigating back cross-origin.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page did enter and was restored from the page cache
+PASS requestAnimationFrame is running after restoring from PageCache.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame.html (0 => 249961)


--- trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-requestAnimationFrame.html	2019-09-17 17:09:49 UTC (rev 249961)
@@ -0,0 +1,58 @@
+<!-- webkit-test-runner [ enablePageCache=true ] -->
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description('Tests that requestAnimationFrame() does not break when restoring from PageCache upon navigating back cross-origin.');
+window.jsTestIsAsync = true;
+
+var restoredFromPageCache = false;
+
+timerHandle = 0;
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+    if (event.persisted) {
+        testPassed("Page did enter and was restored from the page cache");
+        restoredFromPageCache = true;
+        setTimeout(() => {
+            testFailed("requestAnimationFrame did not work after restoring from PageCache.");
+            finishJSTest();
+        }, 10000);
+    }
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+    if (!event.persisted) {
+        testFailed("Page did not enter the page cache.");
+        finishJSTest();
+    }
+}, false);
+
+i = 0;
+function step() {
+    i++;
+    if (i % 10 == 0 && restoredFromPageCache) {
+        testPassed("requestAnimationFrame is running after restoring from PageCache.");
+        clearTimeout(timerHandle);
+        finishJSTest();
+    } else
+        requestAnimationFrame(step);
+}
+requestAnimationFrame(step);
+
+window.addEventListener('load', function() {
+    // This needs to happen in a setTimeout because a navigation inside the onload handler would
+    // not create a history entry.
+    setTimeout(function() {
+      // Force a back navigation back to this page.
+      window.location.href = ""
+    }, 0);
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (249960 => 249961)


--- trunk/Source/WebKit/ChangeLog	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Source/WebKit/ChangeLog	2019-09-17 17:09:49 UTC (rev 249961)
@@ -1,3 +1,28 @@
+2019-09-17  Chris Dumez  <[email protected]>
+
+        REGRESSION (iOS 13): rAF stops firing when navigating away cross-origin and then back
+        https://bugs.webkit.org/show_bug.cgi?id=201767
+        <rdar://problem/55350854>
+
+        Reviewed by Geoffrey Garen.
+
+        When navigating back and restoring a SuspendedPage, WebPage::reinitializeWebPage() ends up
+        reconstructing a new DrawingArea to match the identifier of the DrawingAreaProxy that the
+        UIProcess created. The issue is that when reconstructing the DrawingArea, we were losing
+        the DisplayRefreshMonitors that had been registered on the previous drawing area. To
+        address the issue, we now make sure to transfer the DisplayRefreshMonitors over from the
+        old to the new drawing area. This patch is kept as small as possible to faciliate cherry
+        picking to a branch. However, I think we should consider refactoring the code so that
+        we no longer need to re-create the DrawingArea in the WebProcess in this case.
+
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::adoptDisplayRefreshMonitorsFromDrawingArea):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::adoptDisplayRefreshMonitorsFromDrawingArea):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::reinitializeWebPage):
+
 2019-09-17  Truitt Savell  <[email protected]>
 
         Unreviewed, rolling out r249950.

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (249960 => 249961)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2019-09-17 17:09:49 UTC (rev 249961)
@@ -147,6 +147,7 @@
 #endif
 
     virtual void adoptLayersFromDrawingArea(DrawingArea&) { }
+    virtual void adoptDisplayRefreshMonitorsFromDrawingArea(DrawingArea&) { }
 
     void removeMessageReceiverIfNeeded();
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (249960 => 249961)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2019-09-17 17:09:49 UTC (rev 249961)
@@ -60,6 +60,7 @@
     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
     void updateGeometry(const WebCore::IntSize& viewSize, bool flushSynchronously, const WTF::MachSendRight& fencePort) override;
+    void adoptDisplayRefreshMonitorsFromDrawingArea(DrawingArea&) override;
 
     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (249960 => 249961)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2019-09-17 17:09:49 UTC (rev 249961)
@@ -116,6 +116,15 @@
         m_displayRefreshMonitorsToNotify->remove(remoteMonitor);
 }
 
+void RemoteLayerTreeDrawingArea::adoptDisplayRefreshMonitorsFromDrawingArea(DrawingArea& drawingArea)
+{
+    if (is<RemoteLayerTreeDrawingArea>(drawingArea)) {
+        auto& otherDrawingArea = downcast<RemoteLayerTreeDrawingArea>(drawingArea);
+        m_displayRefreshMonitors = WTFMove(otherDrawingArea.m_displayRefreshMonitors);
+        otherDrawingArea.m_displayRefreshMonitorsToNotify = nullptr;
+    }
+}
+
 void RemoteLayerTreeDrawingArea::updateRootLayers()
 {
     Vector<Ref<GraphicsLayer>> children;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (249960 => 249961)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-09-17 17:09:49 UTC (rev 249961)
@@ -762,6 +762,7 @@
         m_drawingArea->enablePainting();
 
         m_drawingArea->adoptLayersFromDrawingArea(*oldDrawingArea);
+        m_drawingArea->adoptDisplayRefreshMonitorsFromDrawingArea(*oldDrawingArea);
 
         unfreezeLayerTree(LayerTreeFreezeReason::PageSuspended);
     }

Modified: trunk/Tools/DumpRenderTree/TestOptions.cpp (249960 => 249961)


--- trunk/Tools/DumpRenderTree/TestOptions.cpp	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Tools/DumpRenderTree/TestOptions.cpp	2019-09-17 17:09:49 UTC (rev 249961)
@@ -81,6 +81,8 @@
             enableIntersectionObserver = parseBooleanTestHeaderValue(value);
         else if (key == "useEphemeralSession")
             useEphemeralSession = parseBooleanTestHeaderValue(value);
+        else if (key == "enablePageCache")
+            enablePageCache = parseBooleanTestHeaderValue(value);
         else if (key == "enableMenuItemElement")
             enableMenuItemElement = parseBooleanTestHeaderValue(value);
         else if (key == "enableKeygenElement")

Modified: trunk/Tools/DumpRenderTree/TestOptions.h (249960 => 249961)


--- trunk/Tools/DumpRenderTree/TestOptions.h	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Tools/DumpRenderTree/TestOptions.h	2019-09-17 17:09:49 UTC (rev 249961)
@@ -33,6 +33,7 @@
     bool useAcceleratedDrawing { false };
     bool enableIntersectionObserver { false };
     bool useEphemeralSession { false };
+    bool enablePageCache { false };
     bool enableMenuItemElement { false };
     bool enableKeygenElement { false };
     bool enableModernMediaControls { true };

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (249960 => 249961)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2019-09-17 17:09:49 UTC (rev 249961)
@@ -1028,6 +1028,7 @@
     preferences.resizeObserverEnabled = options.enableResizeObserver;
     preferences.coreMathMLEnabled = options.enableCoreMathML;
     preferences.privateBrowsingEnabled = options.useEphemeralSession;
+    preferences.usesPageCache = options.enablePageCache;
 }
 
 // Called once on DumpRenderTree startup.

Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (249960 => 249961)


--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2019-09-17 16:49:49 UTC (rev 249960)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2019-09-17 17:09:49 UTC (rev 249961)
@@ -912,6 +912,7 @@
     prefsPrivate->setIsSecureContextAttributeEnabled(options.enableIsSecureContextAttribute);
     prefsPrivate->setInspectorAdditionsEnabled(options.enableInspectorAdditions);
     preferences->setPrivateBrowsingEnabled(options.useEphemeralSession);
+    preferences->setUsesPageCache(options.enablePageCache);
 }
 
 static String applicationId()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to