Get rid of WebPage::m_shouldResetDrawingAreaAfterSuspend flag
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:28:09 +0000 (21:28 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:28:09 +0000 (21:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196210
<rdar://problem/48681326>

Reviewed by Geoffrey Garen.

Get rid of WebPage::m_shouldResetDrawingAreaAfterSuspend flag and use the drawing area identifier
instead to reset the DrawingArea in the WebProcess whenever the UIProcess did.

This is less error-prone and guarantees that the WebProcess and the UIProcess can reliably
communicate via DrawingArea IPC.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::reinitializeWebPage):
(WebKit::WebPage::setIsSuspended):
* WebProcess/WebPage/WebPage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243461 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h

index 835af79..1eaa084 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-25  Chris Dumez  <cdumez@apple.com>
+
+        Get rid of WebPage::m_shouldResetDrawingAreaAfterSuspend flag
+        https://bugs.webkit.org/show_bug.cgi?id=196210
+        <rdar://problem/48681326>
+
+        Reviewed by Geoffrey Garen.
+
+        Get rid of WebPage::m_shouldResetDrawingAreaAfterSuspend flag and use the drawing area identifier
+        instead to reset the DrawingArea in the WebProcess whenever the UIProcess did.
+
+        This is less error-prone and guarantees that the WebProcess and the UIProcess can reliably
+        communicate via DrawingArea IPC.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::reinitializeWebPage):
+        (WebKit::WebPage::setIsSuspended):
+        * WebProcess/WebPage/WebPage.h:
+
 2019-03-25  Alex Christensen  <achristensen@webkit.org>
 
         Enable IPC sending and receiving non-default-constructible types
index 71a6e70..a7cf18e 100644 (file)
@@ -724,10 +724,10 @@ void WebPage::reinitializeWebPage(WebPageCreationParameters&& parameters)
 
     setSize(parameters.viewSize);
 
-    if (m_shouldResetDrawingAreaAfterSuspend) {
+    // If the UIProcess created a new DrawingArea, then we need to do the same.
+    if (m_drawingArea->identifier() != parameters.drawingAreaIdentifier) {
         auto oldDrawingArea = std::exchange(m_drawingArea, nullptr);
         oldDrawingArea->removeMessageReceiverIfNeeded();
-        m_shouldResetDrawingAreaAfterSuspend = false;
 
         m_drawingArea = DrawingArea::create(*this, parameters);
         m_drawingArea->setPaintingEnabled(false);
@@ -739,7 +739,6 @@ void WebPage::reinitializeWebPage(WebPageCreationParameters&& parameters)
 
         unfreezeLayerTree(LayerTreeFreezeReason::PageSuspended);
     }
-    RELEASE_ASSERT(m_drawingArea->identifier() == parameters.drawingAreaIdentifier);
 
     setViewLayoutSize(parameters.viewLayoutSize);
 
@@ -6321,15 +6320,15 @@ void WebPage::setIsSuspended(bool suspended)
 
     m_isSuspended = suspended;
 
-    if (m_isSuspended) {
-        // Unfrozen on drawing area reset.
-        freezeLayerTree(LayerTreeFreezeReason::PageSuspended);
+    if (!suspended)
+        return;
 
-        WebProcess::singleton().sendPrewarmInformation(mainWebFrame()->url());
+    // Unfrozen on drawing area reset.
+    freezeLayerTree(LayerTreeFreezeReason::PageSuspended);
 
-        suspendForProcessSwap();
-    } else
-        m_shouldResetDrawingAreaAfterSuspend = true;
+    WebProcess::singleton().sendPrewarmInformation(mainWebFrame()->url());
+
+    suspendForProcessSwap();
 }
 
 void WebPage::frameBecameRemote(uint64_t frameID, GlobalFrameIdentifier&& remoteFrameIdentifier, GlobalWindowIdentifier&& remoteWindowIdentifier)
index 717c498..81b692c 100644 (file)
@@ -1561,7 +1561,6 @@ private:
 
     WebCore::IntSize m_viewSize;
     std::unique_ptr<DrawingArea> m_drawingArea;
-    bool m_shouldResetDrawingAreaAfterSuspend { false };
 
     HashSet<PluginView*> m_pluginViews;
     bool m_hasSeenPlugin { false };