Diff
Modified: trunk/Source/WebKit/ChangeLog (237479 => 237480)
--- trunk/Source/WebKit/ChangeLog 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/ChangeLog 2018-10-26 20:11:43 UTC (rev 237480)
@@ -1,5 +1,48 @@
2018-10-26 Chris Dumez <[email protected]>
+ [PSON] Only delay attaching drawingArea in case of process swap and drop DidCompletePageTransition IPC handshake
+ https://bugs.webkit.org/show_bug.cgi?id=190971
+
+ Reviewed by Geoffrey Garen.
+
+ Only delay attaching drawingArea in case of process swap and drop DidCompletePageTransition IPC handshake.
+
+ Since r236257, the WebProcess would always delay attaching the drawing area when a new WebPage is created. The
+ WebProcess would send a DidCompletePageTransition IPC to the UIProcess when the page transition is complete and
+ the UIProcess would then send an IPC back to attach the drawing area.
+
+ In the new design, WebPageCreationParameters contains a flag indicating if the WebPage should delay attaching
+ the drawing area or not. We only delay attaching in case of process swap and we've successfuly suspended the
+ previous page. Then when WebPage::didCompletePageTransition(), we stop sending the DidCompletePageTransition
+ IPC to the UIProcess and instead have the WebProcess attach the drawing area right away if we've delayed
+ attaching until then.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/DrawingAreaProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::suspendCurrentPageIfPossible):
+ (WebKit::WebPageProxy::swapToWebProcess):
+ (WebKit::WebPageProxy::finishAttachingToWebProcess):
+ (WebKit::WebPageProxy::initializeWebPage):
+ (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+ * WebProcess/WebPage/DrawingArea.messages.in:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::m_shouldAttachDrawingAreaOnPageTransition):
+ (WebKit::WebPage::reinitializeWebPage):
+ (WebKit::WebPage::didCompletePageTransition):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+ (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+
+2018-10-26 Chris Dumez <[email protected]>
+
[PSON] Avoid tearing down the drawing area when suspending a WebPage due to process-swap
https://bugs.webkit.org/show_bug.cgi?id=190879
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (237479 => 237480)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-10-26 20:11:43 UTC (rev 237480)
@@ -82,6 +82,7 @@
encoder << colorSpace;
encoder << useSystemAppearance;
encoder << useDarkAppearance;
+ encoder << shouldDelayAttachingDrawingArea;
#endif
#if PLATFORM(IOS_FAMILY)
encoder << screenSize;
@@ -243,6 +244,8 @@
return std::nullopt;
if (!decoder.decode(parameters.useDarkAppearance))
return std::nullopt;
+ if (!decoder.decode(parameters.shouldDelayAttachingDrawingArea))
+ return std::nullopt;
#endif
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (237479 => 237480)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-10-26 20:11:43 UTC (rev 237480)
@@ -139,6 +139,7 @@
ColorSpaceData colorSpace;
bool useSystemAppearance;
bool useDarkAppearance;
+ bool shouldDelayAttachingDrawingArea { false };
#endif
#if PLATFORM(IOS_FAMILY)
WebCore::FloatSize screenSize;
Modified: trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h 2018-10-26 20:11:43 UTC (rev 237480)
@@ -82,8 +82,6 @@
void viewExposedRectChangedTimerFired();
#endif
- virtual void attachInWebProcess() { }
-
virtual void updateDebugIndicator() { }
virtual void waitForDidUpdateActivityState(ActivityStateChangeID) { }
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-10-26 20:11:43 UTC (rev 237480)
@@ -712,26 +712,23 @@
finishAttachingToWebProcess();
}
-void WebPageProxy::suspendCurrentPageIfPossible(API::Navigation& navigation, std::optional<uint64_t> mainFrameID)
+bool WebPageProxy::suspendCurrentPageIfPossible(API::Navigation& navigation, std::optional<uint64_t> mainFrameID)
{
if (!mainFrameID)
- return;
+ return false;
auto* currentItem = navigation.fromItem();
if (!currentItem) {
LOG(ProcessSwapping, "WebPageProxy %" PRIu64 " unable to create suspended page for process pid %i - No current back/forward item", pageID(), m_process->processIdentifier());
- return;
+ return false;
}
auto suspendedPage = std::make_unique<SuspendedPageProxy>(*this, m_process.copyRef(), *currentItem, *mainFrameID);
-#if PLATFORM(MAC)
- m_pageSuspendedDueToCurrentNavigation = makeWeakPtr(suspendedPage.get());
-#endif
-
LOG(ProcessSwapping, "WebPageProxy %" PRIu64 " created suspended page %s for process pid %i, back/forward item %s" PRIu64, pageID(), suspendedPage->loggingString(), m_process->processIdentifier(), currentItem->itemID().logString());
m_process->processPool().addSuspendedPageProxy(WTFMove(suspendedPage));
+ return true;
}
void WebPageProxy::swapToWebProcess(Ref<WebProcessProxy>&& process, API::Navigation& navigation, std::optional<uint64_t> mainFrameIDInPreviousProcess)
@@ -749,7 +746,7 @@
}
m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
- suspendCurrentPageIfPossible(navigation, mainFrameIDInPreviousProcess);
+ bool didSuspendPreviousPage = suspendCurrentPageIfPossible(navigation, mainFrameIDInPreviousProcess);
m_process->removeWebPage(*this, m_pageID);
m_process = WTFMove(process);
@@ -766,10 +763,10 @@
m_process->frameCreated(destinationSuspendedPage->mainFrameID(), *m_mainFrame);
}
- finishAttachingToWebProcess();
+ finishAttachingToWebProcess(didSuspendPreviousPage ? ShouldDelayAttachingDrawingArea::Yes : ShouldDelayAttachingDrawingArea::No);
}
-void WebPageProxy::finishAttachingToWebProcess()
+void WebPageProxy::finishAttachingToWebProcess(ShouldDelayAttachingDrawingArea shouldDelayAttachingDrawingArea)
{
ASSERT(m_process->state() != ChildProcessProxy::State::Terminated);
@@ -805,7 +802,7 @@
m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
#endif
- initializeWebPage();
+ initializeWebPage(shouldDelayAttachingDrawingArea);
pageClient().didRelaunchProcess();
m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
@@ -850,7 +847,7 @@
return WTFMove(navigation);
}
-void WebPageProxy::initializeWebPage()
+void WebPageProxy::initializeWebPage(ShouldDelayAttachingDrawingArea shouldDelayAttachingDrawingArea)
{
ASSERT(isValid());
@@ -868,6 +865,11 @@
#endif
auto parameters = creationParameters();
+#if PLATFORM(MAC)
+ parameters.shouldDelayAttachingDrawingArea = shouldDelayAttachingDrawingArea == ShouldDelayAttachingDrawingArea::Yes;
+#else
+ UNUSED_PARAM(shouldDelayAttachingDrawingArea);
+#endif
#if ENABLE(SERVICE_WORKER)
parameters.hasRegisteredServiceWorkers = process().processPool().mayHaveRegisteredServiceWorkers(m_websiteDataStore);
@@ -2495,12 +2497,6 @@
}
if (policyAction == PolicyAction::Use && frame.isMainFrame()) {
-#if PLATFORM(MAC)
- // We're about to navigate so we need to reset m_pageSuspendedDueToCurrentNavigation. If we decide to process swap,
- // continueNavigationInNewProcess() will take care of updating m_pageSuspendedDueToCurrentNavigation as needed.
- m_pageSuspendedDueToCurrentNavigation = nullptr;
-#endif
-
String reason;
auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, processSwapRequestedByClient, policyAction, reason);
ASSERT(!reason.isNull());
@@ -3520,23 +3516,6 @@
m_pageLoadState.commitChanges();
}
-void WebPageProxy::didCompletePageTransition(bool isInitialEmptyDocument)
-{
-#if PLATFORM(MAC)
- // Attach drawing area for the initial empty document only if this is not a process swap.
- if (isInitialEmptyDocument && m_pageSuspendedDueToCurrentNavigation)
- return;
-
- if (!m_drawingArea)
- return;
-
- // Drawing area for the suspended page will be torn down when the attach completes.
- m_drawingArea->attachInWebProcess();
-#else
- UNUSED_PARAM(isInitialEmptyDocument);
-#endif
-}
-
void WebPageProxy::setNetworkRequestsInProgress(bool networkRequestsInProgress)
{
auto transaction = m_pageLoadState.transaction();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-10-26 20:11:43 UTC (rev 237480)
@@ -438,7 +438,8 @@
API::IconLoadingClient& iconLoadingClient() { return *m_iconLoadingClient; }
void setIconLoadingClient(std::unique_ptr<API::IconLoadingClient>&&);
- void initializeWebPage();
+ enum class ShouldDelayAttachingDrawingArea { No, Yes };
+ void initializeWebPage(ShouldDelayAttachingDrawingArea = ShouldDelayAttachingDrawingArea::No);
WeakPtr<SecKeyProxyStore> secKeyProxyStore(const WebCore::AuthenticationChallenge&);
@@ -1378,7 +1379,7 @@
void updateThrottleState();
void updateHiddenPageThrottlingAutoIncreases();
- void suspendCurrentPageIfPossible(API::Navigation&, std::optional<uint64_t> mainFrameID);
+ bool suspendCurrentPageIfPossible(API::Navigation&, std::optional<uint64_t> mainFrameID);
enum class ResetStateReason {
PageInvalidated,
@@ -1441,7 +1442,6 @@
void didStartProgress();
void didChangeProgress(double);
void didFinishProgress();
- void didCompletePageTransition(bool isInitialEmptyDocument);
void setNetworkRequestsInProgress(bool);
void hasInsecureContent(WebCore::HasInsecureContent&);
@@ -1528,8 +1528,9 @@
void reattachToWebProcess();
void swapToWebProcess(Ref<WebProcessProxy>&&, API::Navigation&, std::optional<uint64_t> mainFrameIDInPreviousProcess);
- void finishAttachingToWebProcess();
+ void finishAttachingToWebProcess(ShouldDelayAttachingDrawingArea = ShouldDelayAttachingDrawingArea::No);
+
RefPtr<API::Navigation> reattachToWebProcessForReload();
RefPtr<API::Navigation> reattachToWebProcessWithItem(WebBackForwardListItem&);
@@ -2259,11 +2260,6 @@
std::optional<MonotonicTime> m_pageLoadStart;
-#if PLATFORM(MAC)
- // FIXME: We should try and get rid of this data member.
- WeakPtr<SuspendedPageProxy> m_pageSuspendedDueToCurrentNavigation;
-#endif
-
RunLoop::Timer<WebPageProxy> m_resetRecentCrashCountTimer;
unsigned m_recentCrashCount { 0 };
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-10-26 20:11:43 UTC (rev 237480)
@@ -117,8 +117,6 @@
DidFinishProgress()
DidStartProgress()
- DidCompletePageTransition(bool isInitialEmptyDocument)
-
SetNetworkRequestsInProgress(bool networkRequestsInProgress)
# Frame lifetime messages
Modified: trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h 2018-10-26 20:11:43 UTC (rev 237480)
@@ -38,8 +38,6 @@
private:
// DrawingAreaProxy
- void attachInWebProcess() override;
-
void deviceScaleFactorDidChange() override;
void sizeDidChange() override;
void colorSpaceDidChange() override;
Modified: trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (237479 => 237480)
--- trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2018-10-26 20:11:43 UTC (rev 237480)
@@ -53,11 +53,6 @@
m_callbacks.invalidate(CallbackBase::Error::OwnerWasInvalidated);
}
-void TiledCoreAnimationDrawingAreaProxy::attachInWebProcess()
-{
- m_webPageProxy.process().send(Messages::DrawingArea::Attach(), m_webPageProxy.pageID());
-}
-
void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
{
m_webPageProxy.process().send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy.deviceScaleFactor()), m_webPageProxy.pageID());
Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in (237479 => 237480)
--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in 2018-10-26 20:11:43 UTC (rev 237480)
@@ -46,8 +46,6 @@
#endif
#if PLATFORM(MAC)
- Attach()
-
#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
DisplayWasRefreshed()
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (237479 => 237480)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-10-26 20:11:43 UTC (rev 237480)
@@ -394,6 +394,9 @@
, m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
, m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
, m_cpuLimit(parameters.cpuLimit)
+#if PLATFORM(MAC)
+ , m_shouldAttachDrawingAreaOnPageTransition(parameters.shouldDelayAttachingDrawingArea)
+#endif
{
ASSERT(m_pageID);
@@ -666,6 +669,9 @@
m_drawingArea->setShouldScaleViewToFitDocument(parameters.shouldScaleViewToFitDocument);
m_drawingArea->updatePreferences(parameters.store);
m_drawingArea->setPaintingEnabled(true);
+#if PLATFORM(MAC)
+ m_shouldAttachDrawingAreaOnPageTransition = parameters.shouldDelayAttachingDrawingArea;
+#endif
}
if (m_activityState != parameters.activityState)
@@ -2998,8 +3004,18 @@
// FIXME: Layer tree freezing should be managed entirely in the UI process side.
setLayerTreeStateIsFrozen(false);
+#if PLATFORM(MAC)
bool isInitialEmptyDocument = !m_mainFrame;
- send(Messages::WebPageProxy::DidCompletePageTransition(isInitialEmptyDocument));
+ if (m_shouldAttachDrawingAreaOnPageTransition && !isInitialEmptyDocument) {
+ m_shouldAttachDrawingAreaOnPageTransition = false;
+ // Unfreezing the layer tree above schedules a layer flush so we delay attaching the drawing area
+ // after the next event loop iteration.
+ RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this)] {
+ if (weakThis && m_drawingArea)
+ m_drawingArea->attach();
+ });
+ }
+#endif
}
void WebPage::show()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (237479 => 237480)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-10-26 20:11:43 UTC (rev 237480)
@@ -1747,6 +1747,9 @@
bool m_isSuspended { false };
bool m_needsFontAttributes { false };
+#if PLATFORM(MAC)
+ bool m_shouldAttachDrawingAreaOnPageTransition { false };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (237479 => 237480)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2018-10-26 19:54:24 UTC (rev 237479)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2018-10-26 20:11:43 UTC (rev 237480)
@@ -91,6 +91,9 @@
updateLayerHostingContext();
setColorSpace(parameters.colorSpace);
+
+ if (!parameters.shouldDelayAttachingDrawingArea)
+ attach();
}
TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()