dispatchViewStateChange should not wait for sync reply if the page isn't visible
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 02:36:28 +0000 (02:36 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 02:36:28 +0000 (02:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145242
<rdar://problem/20967937>

Reviewed by Ben Poulain.

This is particularly problematic on iOS, since if the page isn't visible the process is likely suspended.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchViewStateChange):
(WebKit::WebPageProxy::waitForDidUpdateViewState):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp

index 69e746aa865a38f7423dfb6ae49b9cf36d820a51..62c8fc22fa124b23c05da785768e59ded0303630 100644 (file)
@@ -1,3 +1,18 @@
+2015-05-20  Gavin Barraclough  <barraclough@apple.com>
+
+        dispatchViewStateChange should not wait for sync reply if the page isn't visible
+        https://bugs.webkit.org/show_bug.cgi?id=145242
+        <rdar://problem/20967937>
+
+        Reviewed by Ben Poulain.
+
+        This is particularly problematic on iOS, since if the page isn't visible the process is likely suspended.
+
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dispatchViewStateChange):
+        (WebKit::WebPageProxy::waitForDidUpdateViewState):
+
 2015-05-20  Marcos Chavarría Teijeiro  <mchavarria@igalia.com>
 
         Enable disk cache for range requests
index b34171f1b4ea8a1b8b31d1d27992e7581fc3a9da..2f4a7cfd9f39eced419cc109468c464cd71c09ba 100644 (file)
@@ -1372,6 +1372,10 @@ void WebPageProxy::dispatchViewStateChange()
     if (m_viewWasEverInWindow && (changed & ViewState::IsInWindow) && isInWindow())
         m_viewStateChangeWantsSynchronousReply = true;
 
+    // Don't wait synchronously if the view state is not visible. (This matters in particular on iOS, where a hidden page may be suspended.)
+    if (!(m_viewState & ViewState::IsVisible))
+        m_viewStateChangeWantsSynchronousReply = false;
+
     if (changed || m_viewStateChangeWantsSynchronousReply || !m_nextViewStateChangeCallbacks.isEmpty())
         m_process->send(Messages::WebPage::SetViewState(m_viewState, m_viewStateChangeWantsSynchronousReply, m_nextViewStateChangeCallbacks), m_pageID);
 
@@ -1450,6 +1454,15 @@ void WebPageProxy::waitForDidUpdateViewState()
     if (m_waitingForDidUpdateViewState)
         return;
 
+#if PLATFORM(IOS)
+    // Hail Mary check. Should not be possible (dispatchViewStateChange should force async if not visible,
+    // and if visible we should be holding an assertion) - but we should never block on a suspended process.
+    if (!m_activityToken) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+#endif
+
     m_waitingForDidUpdateViewState = true;
 
     m_drawingArea->waitForDidUpdateViewState();