Changeset 245198 in webkit
- Timestamp:
- May 10, 2019 4:25:28 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r245196 r245198 1 2019-05-10 Chris Dumez <cdumez@apple.com> 2 3 [PSON] Prevent flashing when the process-swap is forced by the client 4 https://bugs.webkit.org/show_bug.cgi?id=197799 5 6 Reviewed by Geoffrey Garen. 7 8 When the process-swap is forced by the client, we would not construct a SuspendedPageProxy for 9 the previous page, which would cause a white/black flash upon navigation on macOS. The reason 10 we did not construct a SuspendedPageProxy is that it would be unsafe to keep the page around 11 in this case because other windows might have an opener link to the page when the swap is forced 12 and we need those opener / openee links to get severed. 13 14 The new approach to maintain the Web facing behavior without flashing is to create a suspended 15 page proxy for the previous page when the process swap is forced by the client. We then close 16 the page as soon as we can do so without flashing (when pageEnteredAcceleratedCompositingMode() 17 has been called). 18 19 * UIProcess/SuspendedPageProxy.cpp: 20 (WebKit::SuspendedPageProxy::SuspendedPageProxy): 21 (WebKit::SuspendedPageProxy::close): 22 (WebKit::SuspendedPageProxy::pageEnteredAcceleratedCompositingMode): 23 (WebKit::SuspendedPageProxy::closeWithoutFlashing): 24 (WebKit::SuspendedPageProxy::didProcessRequestToSuspend): 25 * UIProcess/SuspendedPageProxy.h: 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::suspendCurrentPageIfPossible): 28 (WebKit::WebPageProxy::commitProvisionalPage): 29 * UIProcess/WebPageProxy.h: 30 1 31 2019-05-10 Brent Fulgham <bfulgham@apple.com> 2 32 -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp
r244464 r245198 79 79 #endif 80 80 81 SuspendedPageProxy::SuspendedPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, uint64_t mainFrameID )81 SuspendedPageProxy::SuspendedPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, uint64_t mainFrameID, ShouldDelayClosingUntilEnteringAcceleratedCompositingMode shouldDelayClosingUntilEnteringAcceleratedCompositingMode) 82 82 : m_page(page) 83 83 , m_process(WTFMove(process)) 84 84 , m_mainFrameID(mainFrameID) 85 #if PLATFORM(MAC) 86 , m_shouldDelayClosingOnFailure(m_page.drawingArea() && m_page.drawingArea()->type() == DrawingAreaTypeTiledCoreAnimation) 87 #endif 85 , m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode(shouldDelayClosingUntilEnteringAcceleratedCompositingMode) 88 86 , m_suspensionTimeoutTimer(RunLoop::main(), this, &SuspendedPageProxy::suspensionTimedOut) 89 87 #if PLATFORM(IOS_FAMILY) … … 160 158 return; 161 159 160 RELEASE_LOG(ProcessSwapping, "%p - SuspendedPageProxy::close()", this); 162 161 m_isClosed = true; 163 162 m_process->send(Messages::WebPage::Close(), m_page.pageID()); … … 166 165 void SuspendedPageProxy::pageEnteredAcceleratedCompositingMode() 167 166 { 168 m_shouldDelayClosing OnFailure = false;169 170 if (m_suspensionState == SuspensionState::FailedToSuspend ) {171 // We needed the failedsuspended page to stay alive to avoid flashing. Now we can get rid of it.167 m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode = ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::No; 168 169 if (m_suspensionState == SuspensionState::FailedToSuspend || m_shouldCloseWhenEnteringAcceleratedCompositingMode) { 170 // We needed the suspended page to stay alive to avoid flashing. Now we can get rid of it. 172 171 close(); 173 172 } 173 } 174 175 void SuspendedPageProxy::closeWithoutFlashing() 176 { 177 RELEASE_LOG(ProcessSwapping, "%p - SuspendedPageProxy::closeWithoutFlashing() shouldDelayClosingUntilEnteringAcceleratedCompositingMode? %d", this, m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode == ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::Yes); 178 if (m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode == ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::Yes) { 179 m_shouldCloseWhenEnteringAcceleratedCompositingMode = true; 180 return; 181 } 182 close(); 174 183 } 175 184 … … 192 201 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID()); 193 202 194 if (m_suspensionState == SuspensionState::FailedToSuspend && !m_shouldDelayClosingOnFailure)203 if (m_suspensionState == SuspensionState::FailedToSuspend && m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode == ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::No) 195 204 close(); 196 205 -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h
r244144 r245198 38 38 class WebProcessProxy; 39 39 40 enum class ShouldDelayClosingUntilEnteringAcceleratedCompositingMode : bool { No, Yes }; 41 40 42 class SuspendedPageProxy final: public IPC::MessageReceiver, public CanMakeWeakPtr<SuspendedPageProxy> { 41 43 WTF_MAKE_FAST_ALLOCATED; 42 44 public: 43 SuspendedPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, uint64_t mainFrameID );45 SuspendedPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, uint64_t mainFrameID, ShouldDelayClosingUntilEnteringAcceleratedCompositingMode); 44 46 ~SuspendedPageProxy(); 45 47 … … 52 54 void waitUntilReadyToUnsuspend(CompletionHandler<void(SuspendedPageProxy*)>&&); 53 55 void unsuspend(); 54 void close();55 56 56 57 void pageEnteredAcceleratedCompositingMode(); 58 void closeWithoutFlashing(); 57 59 58 60 #if !LOG_DISABLED … … 65 67 void suspensionTimedOut(); 66 68 69 void close(); 70 67 71 // IPC::MessageReceiver 68 72 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; … … 73 77 uint64_t m_mainFrameID; 74 78 bool m_isClosed { false }; 75 bool m_shouldDelayClosingOnFailure { false }; 79 ShouldDelayClosingUntilEnteringAcceleratedCompositingMode m_shouldDelayClosingUntilEnteringAcceleratedCompositingMode { ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::No }; 80 bool m_shouldCloseWhenEnteringAcceleratedCompositingMode { false }; 76 81 77 82 SuspensionState m_suspensionState { SuspensionState::Suspending }; -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r245185 r245198 743 743 } 744 744 745 bool WebPageProxy::suspendCurrentPageIfPossible(API::Navigation& navigation, Optional<uint64_t> mainFrameID, ProcessSwapRequestedByClient processSwapRequestedByClient )745 bool WebPageProxy::suspendCurrentPageIfPossible(API::Navigation& navigation, Optional<uint64_t> mainFrameID, ProcessSwapRequestedByClient processSwapRequestedByClient, ShouldDelayClosingUntilEnteringAcceleratedCompositingMode shouldDelayClosingUntilEnteringAcceleratedCompositingMode) 746 746 { 747 747 m_lastSuspendedPage = nullptr; … … 749 749 if (!mainFrameID) 750 750 return false; 751 752 // If the client forced a swap then it may not be Web-compatible to suspend the previous page because other windows may have an opener link to the page.753 if (processSwapRequestedByClient == ProcessSwapRequestedByClient::Yes) {754 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Not suspending current page for process pid %i because the swap was requested by the client", m_process->processIdentifier());755 return false;756 }757 751 758 752 if (!hasCommittedAnyProvisionalLoads()) { … … 782 776 783 777 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Suspending current page for process pid %i", m_process->processIdentifier()); 784 auto suspendedPage = std::make_unique<SuspendedPageProxy>(*this, m_process.copyRef(), *mainFrameID );778 auto suspendedPage = std::make_unique<SuspendedPageProxy>(*this, m_process.copyRef(), *mainFrameID, shouldDelayClosingUntilEnteringAcceleratedCompositingMode); 785 779 786 780 LOG(ProcessSwapping, "WebPageProxy %" PRIu64 " created suspended page %s for process pid %i, back/forward item %s" PRIu64, pageID(), suspendedPage->loggingString(), m_process->processIdentifier(), fromItem ? fromItem->itemID().logString() : 0); 781 782 // If the client forced a swap then it may not be web-compatible to keep the previous page because other windows may have an opener link to it. We thus close it as soon as we 783 // can do so without flashing. 784 if (processSwapRequestedByClient == ProcessSwapRequestedByClient::Yes) 785 suspendedPage->closeWithoutFlashing(); 787 786 788 787 if (fromItem && m_preferences->usesPageCache()) … … 2885 2884 ASSERT(m_process.ptr() != &m_provisionalPage->process()); 2886 2885 2886 auto shouldDelayClosingUntilEnteringAcceleratedCompositingMode = ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::No; 2887 #if PLATFORM(MAC) 2888 // On macOS, when not using UI-side compositing, we need to make sure we do not close the page in the previous process until we've 2889 // entered accelerated compositing for the new page or we will flash on navigation. 2890 if (drawingArea()->type() == DrawingAreaTypeTiledCoreAnimation) 2891 shouldDelayClosingUntilEnteringAcceleratedCompositingMode = ShouldDelayClosingUntilEnteringAcceleratedCompositingMode::Yes; 2892 #endif 2893 2887 2894 processDidTerminate(ProcessTerminationReason::NavigationSwap); 2888 2895 2889 2896 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID); 2890 2897 auto* navigation = navigationState().navigation(m_provisionalPage->navigationID()); 2891 bool didSuspendPreviousPage = navigation ? suspendCurrentPageIfPossible(*navigation, mainFrameIDInPreviousProcess, m_provisionalPage->processSwapRequestedByClient() ) : false;2898 bool didSuspendPreviousPage = navigation ? suspendCurrentPageIfPossible(*navigation, mainFrameIDInPreviousProcess, m_provisionalPage->processSwapRequestedByClient(), shouldDelayClosingUntilEnteringAcceleratedCompositingMode) : false; 2892 2899 m_process->removeWebPage(*this, m_websiteDataStore.ptr() == &m_provisionalPage->process().websiteDataStore() ? WebProcessProxy::EndsUsingDataStore::No : WebProcessProxy::EndsUsingDataStore::Yes); 2893 2900 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r245079 r245198 1555 1555 void updateHiddenPageThrottlingAutoIncreases(); 1556 1556 1557 bool suspendCurrentPageIfPossible(API::Navigation&, Optional<uint64_t> mainFrameID, ProcessSwapRequestedByClient );1557 bool suspendCurrentPageIfPossible(API::Navigation&, Optional<uint64_t> mainFrameID, ProcessSwapRequestedByClient, ShouldDelayClosingUntilEnteringAcceleratedCompositingMode); 1558 1558 1559 1559 enum class ResetStateReason {
Note: See TracChangeset
for help on using the changeset viewer.