Update process assertions after swapping processes
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 21:20:02 +0000 (21:20 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 21:20:02 +0000 (21:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192318
<rdar://problem/46377552>

Reviewed by Chris Dumez.

If the previous WebProcess had a ProcessAssertion to prevent it from being suspended,
after navigation and process swapping we need the new WebProcess to update its process assertions.

* UIProcess/API/Cocoa/PageLoadStateObserver.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::didSwapWebProcesses):
* UIProcess/PageLoadState.cpp:
(WebKit::PageLoadState::didSwapWebProcesses):
* UIProcess/PageLoadState.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::finishAttachingToWebProcess):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/PageLoadStateObserver.h
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/Cocoa/NavigationState.h
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/PageLoadState.cpp
Source/WebKit/UIProcess/PageLoadState.h
Source/WebKit/UIProcess/WebPageProxy.cpp

index c7f480a..4906483 100644 (file)
@@ -1,3 +1,24 @@
+2018-12-03  Alex Christensen  <achristensen@webkit.org>
+
+        Update process assertions after swapping processes
+        https://bugs.webkit.org/show_bug.cgi?id=192318
+        <rdar://problem/46377552>
+
+        Reviewed by Chris Dumez.
+
+        If the previous WebProcess had a ProcessAssertion to prevent it from being suspended,
+        after navigation and process swapping we need the new WebProcess to update its process assertions.
+
+        * UIProcess/API/Cocoa/PageLoadStateObserver.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::didSwapWebProcesses):
+        * UIProcess/PageLoadState.cpp:
+        (WebKit::PageLoadState::didSwapWebProcesses):
+        * UIProcess/PageLoadState.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::finishAttachingToWebProcess):
+
 2018-12-03  Daniel Bates  <dabates@apple.com>
 
         [iOS] Do not handle key events that are key commands
index 95e9ba2..6828050 100644 (file)
@@ -97,6 +97,7 @@ private:
     void didChangeNetworkRequestsInProgress() override { }
     void willChangeCertificateInfo() override { }
     void didChangeCertificateInfo() override { }
+    void didSwapWebProcesses() override { }
 
     void willChangeWebProcessIsResponsive() override
     {
index 2348596..1bae074 100644 (file)
@@ -354,6 +354,7 @@ private:
     void didChangeCertificateInfo() override { }
     void willChangeWebProcessIsResponsive() override { }
     void didChangeWebProcessIsResponsive() override { }
+    void didSwapWebProcesses() override { };
 
     WebKitWebView* m_webView;
 };
index c02c156..d87c560 100644 (file)
@@ -176,6 +176,7 @@ private:
     void didChangeCertificateInfo() override;
     void willChangeWebProcessIsResponsive() override;
     void didChangeWebProcessIsResponsive() override;
+    void didSwapWebProcesses() override;
 
 #if PLATFORM(IOS_FAMILY)
     void releaseNetworkActivityTokenAfterLoadCompletion() { releaseNetworkActivityToken(NetworkActivityTokenReleaseReason::LoadCompleted); }
index f6f42d9..6f82d54 100644 (file)
@@ -1226,6 +1226,15 @@ void NavigationState::didChangeWebProcessIsResponsive()
     [m_webView didChangeValueForKey:@"_webProcessIsResponsive"];
 }
 
+void NavigationState::didSwapWebProcesses()
+{
+#if PLATFORM(IOS_FAMILY)
+    // Transfer our background assertion from the old process to the new one.
+    if (m_activityToken)
+        m_activityToken = m_webView->_page->process().throttler().backgroundActivityToken();
+#endif
+}
+
 } // namespace WebKit
 
 #endif
index 2ed1075..c2ae6f0 100644 (file)
@@ -407,6 +407,11 @@ bool PageLoadState::isLoading(const Data& data)
     return false;
 }
 
+void PageLoadState::didSwapWebProcesses()
+{
+    callObserverCallback(&Observer::didSwapWebProcesses);
+}
+
 void PageLoadState::willChangeProcessIsResponsive()
 {
     callObserverCallback(&Observer::willChangeWebProcessIsResponsive);
index e2afdfd..cacbce4 100644 (file)
@@ -78,6 +78,8 @@ public:
 
         virtual void willChangeWebProcessIsResponsive() = 0;
         virtual void didChangeWebProcessIsResponsive() = 0;
+        
+        virtual void didSwapWebProcesses() = 0;
     };
 
     class Transaction {
@@ -165,6 +167,8 @@ public:
     void didFinishProgress(const Transaction::Token&);
     void setNetworkRequestsInProgress(const Transaction::Token&, bool);
 
+    void didSwapWebProcesses();
+
     bool committedHasInsecureContent() const { return m_committedState.hasInsecureContent; }
 
     // FIXME: We piggy-back off PageLoadState::Observer so that both WKWebView and WKObservablePageState
index 1a3379e..78a33a8 100644 (file)
@@ -852,6 +852,7 @@ void WebPageProxy::finishAttachingToWebProcess(ShouldDelayAttachingDrawingArea s
     createInspectorTargets();
 
     pageClient().didRelaunchProcess();
+    m_pageLoadState.didSwapWebProcesses();
     m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
 }