Title: [253337] trunk/Source/WebKit
Revision
253337
Author
[email protected]
Date
2019-12-10 12:04:10 -0800 (Tue, 10 Dec 2019)

Log Message

[WK2][iOS] Visibility propagation view is not properly updated when navigating cross-process
https://bugs.webkit.org/show_bug.cgi?id=205028

Reviewed by Tim Horton.

Make sure we keep the contextIDForVisibilityPropagation on the ProvisionalPageProxy / SuspendedPageProxy
objects and update WebPageProxy::m_contextIDForVisibilityPropagation whenever we commit a provisional
page. Also update ProvisionalPageProxy to listen for the WebPageProxy::DidCreateContextForVisibilityPropagation
IPC so that it can update m_contextIDForVisibilityPropagation once the WebPage is created in the
provisional WebProcess (which creates the visibility propagation view).

* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
(WebKit::ProvisionalPageProxy::didCreateContextForVisibilityPropagation):
(WebKit::ProvisionalPageProxy::didReceiveMessage):
* UIProcess/ProvisionalPageProxy.h:
(WebKit::ProvisionalPageProxy::contextIDForVisibilityPropagation const):
* UIProcess/SuspendedPageProxy.cpp:
(WebKit::SuspendedPageProxy::SuspendedPageProxy):
* UIProcess/SuspendedPageProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::swapToProvisionalPage):
(WebKit::WebPageProxy::commitProvisionalPage):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::swapToWebProcess): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _setupVisibilityPropagationView]):
(-[WKContentView _removeVisibilityPropagationView]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (253336 => 253337)


--- trunk/Source/WebKit/ChangeLog	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/ChangeLog	2019-12-10 20:04:10 UTC (rev 253337)
@@ -1,5 +1,37 @@
 2019-12-10  Chris Dumez  <[email protected]>
 
+        [WK2][iOS] Visibility propagation view is not properly updated when navigating cross-process
+        https://bugs.webkit.org/show_bug.cgi?id=205028
+
+        Reviewed by Tim Horton.
+
+        Make sure we keep the contextIDForVisibilityPropagation on the ProvisionalPageProxy / SuspendedPageProxy
+        objects and update WebPageProxy::m_contextIDForVisibilityPropagation whenever we commit a provisional
+        page. Also update ProvisionalPageProxy to listen for the WebPageProxy::DidCreateContextForVisibilityPropagation
+        IPC so that it can update m_contextIDForVisibilityPropagation once the WebPage is created in the
+        provisional WebProcess (which creates the visibility propagation view).
+
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
+        (WebKit::ProvisionalPageProxy::didCreateContextForVisibilityPropagation):
+        (WebKit::ProvisionalPageProxy::didReceiveMessage):
+        * UIProcess/ProvisionalPageProxy.h:
+        (WebKit::ProvisionalPageProxy::contextIDForVisibilityPropagation const):
+        * UIProcess/SuspendedPageProxy.cpp:
+        (WebKit::SuspendedPageProxy::SuspendedPageProxy):
+        * UIProcess/SuspendedPageProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::swapToProvisionalPage):
+        (WebKit::WebPageProxy::commitProvisionalPage):
+        (WebKit::WebPageProxy::resetState):
+        (WebKit::WebPageProxy::swapToWebProcess): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _setupVisibilityPropagationView]):
+        (-[WKContentView _removeVisibilityPropagationView]):
+
+2019-12-10  Chris Dumez  <[email protected]>
+
         Regression(r253277) ASSERTION FAILED: !parameters.request.httpBody() in NetworkConnectionToWebProcess::preconnectTo()
         https://bugs.webkit.org/show_bug.cgi?id=205030
 

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2019-12-10 20:04:10 UTC (rev 253337)
@@ -65,6 +65,9 @@
 #if PLATFORM(IOS_FAMILY)
     , m_provisionalLoadActivity(m_process->throttler().foregroundActivity("Provisional Load"_s))
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    , m_contextIDForVisibilityPropagation(suspendedPage ? suspendedPage->contextIDForVisibilityPropagation() : 0)
+#endif
 {
     RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "ProvisionalPageProxy: pageProxyID=%" PRIu64 " webPageID=%" PRIu64 " navigationID=%" PRIu64 " suspendedPage: %p", m_page.identifier().toUInt64(), m_webPageID.toUInt64(), navigationID, suspendedPage.get());
 
@@ -374,6 +377,14 @@
 }
 #endif
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+void ProvisionalPageProxy::didCreateContextForVisibilityPropagation(LayerHostingContextID contextID)
+{
+    RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "didCreateContextForVisibilityPropagation: contextID=%u pageProxyID=%" PRIu64 " webPageID=%" PRIu64, contextID, m_page.identifier().toUInt64(), m_webPageID.toUInt64());
+    m_contextIDForVisibilityPropagation = contextID;
+}
+#endif
+
 void ProvisionalPageProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
     ASSERT(decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName());
@@ -482,6 +493,13 @@
     }
 #endif
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    if (decoder.messageName() == Messages::WebPageProxy::DidCreateContextForVisibilityPropagation::name()) {
+        IPC::handleMessage<Messages::WebPageProxy::DidCreateContextForVisibilityPropagation>(decoder, this, &ProvisionalPageProxy::didCreateContextForVisibilityPropagation);
+        return;
+    }
+#endif
+
     LOG(ProcessSwapping, "Unhandled message %s::%s from provisional process", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data());
 }
 

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2019-12-10 20:04:10 UTC (rev 253337)
@@ -61,6 +61,10 @@
 struct URLSchemeTaskParameters;
 struct WebNavigationDataStore;
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+using LayerHostingContextID = uint32_t;
+#endif
+
 class ProvisionalPageProxy : public IPC::MessageReceiver, public IPC::MessageSender, public CanMakeWeakPtr<ProvisionalPageProxy> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -83,6 +87,9 @@
 #if PLATFORM(COCOA)
     Vector<uint8_t> takeAccessibilityToken() { return WTFMove(m_accessibilityToken); }
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    LayerHostingContextID contextIDForVisibilityPropagation() const { return m_contextIDForVisibilityPropagation; }
+#endif
 
     void loadData(API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, Optional<WebsitePoliciesData>&& = WTF::nullopt);
     void loadRequest(API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, Optional<WebsitePoliciesData>&& = WTF::nullopt);
@@ -129,6 +136,9 @@
 #if ENABLE(CONTENT_FILTERING)
     void contentFilterDidBlockLoadForFrame(const WebCore::ContentFilterUnblockHandler&, WebCore::FrameIdentifier);
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    void didCreateContextForVisibilityPropagation(LayerHostingContextID);
+#endif
 
     void initializeWebPage();
     bool validateInput(WebCore::FrameIdentifier, const Optional<uint64_t>& navigationID = WTF::nullopt);
@@ -151,6 +161,9 @@
 #if PLATFORM(IOS_FAMILY)
     UniqueRef<ProcessThrottler::ForegroundActivity> m_provisionalLoadActivity;
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    LayerHostingContextID m_contextIDForVisibilityPropagation { 0 };
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp	2019-12-10 20:04:10 UTC (rev 253337)
@@ -104,6 +104,9 @@
 #if PLATFORM(IOS_FAMILY)
     , m_suspensionActivity(m_process->throttler().backgroundActivity("Page suspension for back/forward cache"_s).moveToUniquePtr())
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    , m_contextIDForVisibilityPropagation(page.contextIDForVisibilityPropagation())
+#endif
 {
     allSuspendedPages().add(this);
     m_process->incrementSuspendedPageCount();

Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h	2019-12-10 20:04:10 UTC (rev 253337)
@@ -46,6 +46,10 @@
 class WebProcessProxy;
 class WebsiteDataStore;
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+using LayerHostingContextID = uint32_t;
+#endif
+
 enum class ShouldDelayClosingUntilEnteringAcceleratedCompositingMode : bool { No, Yes };
 
 class SuspendedPageProxy final: public IPC::MessageReceiver, public IPC::MessageSender, public CanMakeWeakPtr<SuspendedPageProxy> {
@@ -71,6 +75,10 @@
     void pageEnteredAcceleratedCompositingMode();
     void closeWithoutFlashing();
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    LayerHostingContextID contextIDForVisibilityPropagation() const { return m_contextIDForVisibilityPropagation; }
+#endif
+
 #if !LOG_DISABLED
     const char* loggingString() const;
 #endif
@@ -105,6 +113,9 @@
 #if PLATFORM(IOS_FAMILY)
     std::unique_ptr<ProcessThrottler::BackgroundActivity> m_suspensionActivity;
 #endif
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    LayerHostingContextID m_contextIDForVisibilityPropagation { 0 };
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-12-10 20:04:10 UTC (rev 253337)
@@ -827,23 +827,27 @@
     return m_preferences->usesBackForwardCache() && backForwardCache().capacity() > 0;
 }
 
-void WebPageProxy::swapToWebProcess(Ref<WebProcessProxy>&& process, PageIdentifier webPageID, std::unique_ptr<DrawingAreaProxy>&& drawingArea, RefPtr<WebFrameProxy>&& mainFrame)
+void WebPageProxy::swapToProvisionalPage(std::unique_ptr<ProvisionalPageProxy> provisionalPage)
 {
     ASSERT(!m_isClosed);
-    RELEASE_LOG_IF_ALLOWED(Loading, "swapToWebProcess: newWebPageID=%" PRIu64, webPageID.toUInt64());
+    RELEASE_LOG_IF_ALLOWED(Loading, "swapToProvisionalPage: newWebPageID=%" PRIu64, provisionalPage->webPageID().toUInt64());
 
-    m_process = WTFMove(process);
-    m_webPageID = webPageID;
+    m_process = provisionalPage->process();
+    m_webPageID = provisionalPage->webPageID();
     pageClient().didChangeWebPageID();
     m_websiteDataStore = m_process->websiteDataStore();
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    m_contextIDForVisibilityPropagation = provisionalPage->contextIDForVisibilityPropagation();
+#endif
+
     if (m_logger)
         m_logger->setEnabled(this, isAlwaysOnLoggingAllowed());
 
     ASSERT(!m_drawingArea);
-    setDrawingArea(WTFMove(drawingArea));
+    setDrawingArea(provisionalPage->takeDrawingArea());
     ASSERT(!m_mainFrame);
-    m_mainFrame = WTFMove(mainFrame);
+    m_mainFrame = provisionalPage->mainFrame();
     m_hasRunningProcess = true;
 
     m_process->addExistingWebPage(*this, WebProcessProxy::BeginsUsingDataStore::No);
@@ -850,6 +854,12 @@
     m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID, *this);
 
     finishAttachingToWebProcess(ProcessLaunchReason::ProcessSwap);
+
+#if PLATFORM(COCOA)
+    auto accessibilityToken = provisionalPage->takeAccessibilityToken();
+    if (!accessibilityToken.isEmpty())
+        registerWebProcessAccessibilityToken({ accessibilityToken.data(), accessibilityToken.size() });
+#endif
 }
 
 void WebPageProxy::finishAttachingToWebProcess(ProcessLaunchReason reason)
@@ -3124,18 +3134,11 @@
         m_process->send(Messages::WebPage::Close(), m_webPageID);
 
     const auto oldWebPageID = m_webPageID;
-    swapToWebProcess(m_provisionalPage->process(), m_provisionalPage->webPageID(), m_provisionalPage->takeDrawingArea(), m_provisionalPage->mainFrame());
+    swapToProvisionalPage(std::exchange(m_provisionalPage, nullptr));
 
-#if PLATFORM(COCOA)
-    auto accessibilityToken = m_provisionalPage->takeAccessibilityToken();
-    if (!accessibilityToken.isEmpty())
-        registerWebProcessAccessibilityToken({ accessibilityToken.data(), accessibilityToken.size() });
-#endif
-
     didCommitLoadForFrame(frameID, navigationID, mimeType, frameHasCustomContentProvider, frameLoadType, certificateInfo, containsPluginDocument, forcedHasInsecureContent, userData);
 
     m_inspectorController->didCommitProvisionalPage(oldWebPageID, m_webPageID);
-    m_provisionalPage = nullptr;
 }
 
 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, Optional<WebsitePoliciesData>&& websitePolicies)
@@ -7233,6 +7236,11 @@
     }
 #endif
 
+#if HAVE(VISIBILITY_PROPAGATION_VIEW)
+    if (resetStateReason != ResetStateReason::NavigationSwap)
+        m_contextIDForVisibilityPropagation = 0;
+#endif
+
     if (m_openPanelResultListener) {
         m_openPanelResultListener->invalidate();
         m_openPanelResultListener = nullptr;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-12-10 20:04:10 UTC (rev 253337)
@@ -1807,7 +1807,7 @@
     };
 
     void launchProcess(const WebCore::RegistrableDomain&, ProcessLaunchReason);
-    void swapToWebProcess(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, std::unique_ptr<DrawingAreaProxy>&&, RefPtr<WebFrameProxy>&& mainFrame);
+    void swapToProvisionalPage(std::unique_ptr<ProvisionalPageProxy>);
     void didFailToSuspendAfterProcessSwap();
     void didSuspendAfterProcessSwap();
     void finishAttachingToWebProcess(ProcessLaunchReason);

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (253336 => 253337)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-12-10 19:51:30 UTC (rev 253336)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2019-12-10 20:04:10 UTC (rev 253337)
@@ -223,12 +223,16 @@
     ASSERT(!_visibilityPropagationView);
     // Propagate the view's visibility state to the WebContent process so that it is marked as "Foreground Running" when necessary.
     _visibilityPropagationView = adoptNS([[_UILayerHostView alloc] initWithFrame:CGRectZero pid:processIdentifier contextID:contextID]);
-    RELEASE_LOG(Process, "Created visibility propagation view %p for WebContent process with PID %d", _visibilityPropagationView.get(), processIdentifier);
+    RELEASE_LOG(Process, "Created visibility propagation view %p (contextID: %u) for WebContent process with PID %d", _visibilityPropagationView.get(), contextID, processIdentifier);
     [self addSubview:_visibilityPropagationView.get()];
 }
 
 - (void)_removeVisibilityPropagationView
 {
+    if (!_visibilityPropagationView)
+        return;
+
+    RELEASE_LOG(Process, "Removing visibility propagation view %p", _visibilityPropagationView.get());
     [_visibilityPropagationView removeFromSuperview];
     _visibilityPropagationView = nullptr;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to