Changeset 244075 in webkit
- Timestamp:
- Apr 9, 2019, 7:20:12 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/SuspendedPageProxy.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/SuspendedPageProxy.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebProcessPool.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244065 r244075 1 2019-04-09 Chris Dumez <cdumez@apple.com> 2 3 Loads using loadHTMLString() cause flashing when process-swapping 4 https://bugs.webkit.org/show_bug.cgi?id=196714 5 <rdar://problem/49637354> 6 7 Reviewed by Antti Koivisto. 8 9 Our logic to decide if we should construct a SuspendedPageProxy on process-swap was assuming 10 a SuspendedPageProxy is only useful for PageCache and would therefore not create one if PageCache 11 is disabled or if there is no associated WebBackForwardListItem. However, constructing a 12 SuspendedPageProxy is also useful to prevent flashing when process-swapping as we need to keep 13 displaying the layer of the previous process until there is something meaningful to show in the 14 new process. 15 16 This patch makes it so that we now construct a SuspendedPageProxy on process-swap, even if 17 PageCache is disabled or if there is no associated WebBackForwardListItem. The process in 18 question will not be useful for PageCache but it will avoid flashing. The SuspendedPageProxy's 19 process may also get used for future navigations to the same site (as demonstrated by the 20 API test) which is beneficial for performance. 21 22 * UIProcess/SuspendedPageProxy.cpp: 23 (WebKit::SuspendedPageProxy::SuspendedPageProxy): 24 * UIProcess/SuspendedPageProxy.h: 25 * UIProcess/WebPageProxy.cpp: 26 (WebKit::WebPageProxy::suspendCurrentPageIfPossible): 27 * UIProcess/WebProcessPool.cpp: 28 (WebKit::WebProcessPool::findReusableSuspendedPageProcess): 29 1 30 2019-04-08 Don Olmstead <don.olmstead@sony.com> 2 31 -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp
r242889 r244075 79 79 #endif 80 80 81 SuspendedPageProxy::SuspendedPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, WebBackForwardListItem& item,uint64_t mainFrameID)81 SuspendedPageProxy::SuspendedPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, uint64_t mainFrameID) 82 82 : m_page(page) 83 83 , m_process(WTFMove(process)) 84 84 , m_mainFrameID(mainFrameID) 85 , m_registrableDomain(URL(URL(), item.url()))86 85 , m_suspensionTimeoutTimer(RunLoop::main(), this, &SuspendedPageProxy::suspensionTimedOut) 87 86 #if PLATFORM(IOS_FAMILY) … … 89 88 #endif 90 89 { 91 item.setSuspendedPage(this);92 90 m_process->incrementSuspendedPageCount(); 93 91 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID(), *this); -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h
r242889 r244075 42 42 WTF_MAKE_FAST_ALLOCATED; 43 43 public: 44 SuspendedPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, WebBackForwardListItem&,uint64_t mainFrameID);44 SuspendedPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, uint64_t mainFrameID); 45 45 ~SuspendedPageProxy(); 46 46 … … 48 48 WebProcessProxy& process() { return m_process.get(); } 49 49 uint64_t mainFrameID() const { return m_mainFrameID; } 50 const WebCore::RegistrableDomain& registrableDomain() const { return m_registrableDomain; }51 50 52 51 bool failedToSuspend() const { return m_suspensionState == SuspensionState::FailedToSuspend; } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r243961 r244075 742 742 return false; 743 743 744 if (!m_preferences->usesPageCache()) {745 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Not suspending current page for process pid %i because page cache is disabled", m_process->processIdentifier());746 return false;747 }748 749 744 // 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. 750 745 if (processSwapRequestedByClient == ProcessSwapRequestedByClient::Yes) { … … 764 759 765 760 auto* fromItem = navigation.fromItem(); 766 if (!fromItem) {767 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Not suspending current page for process pid %i because the navigation does not have a fromItem", m_process->processIdentifier());768 return false;769 }770 761 771 762 // If the source and the destination back / forward list items are the same, then this is a client-side redirect. In this case, 772 763 // there is no need to suspend the previous page as there will be no way to get back to it. 773 if (fromItem == m_backForwardList->currentItem()) {764 if (fromItem && fromItem == m_backForwardList->currentItem()) { 774 765 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Not suspending current page for process pid %i because this is a client-side redirect", m_process->processIdentifier()); 775 766 return false; 776 767 } 777 768 778 if (fromItem ->url() != pageLoadState().url()) {769 if (fromItem && fromItem->url() != pageLoadState().url()) { 779 770 RELEASE_LOG_ERROR_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Not suspending current page for process pid %i because fromItem's URL does not match the page URL.", m_process->processIdentifier()); 780 771 ASSERT_NOT_REACHED(); … … 783 774 784 775 RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "suspendCurrentPageIfPossible: Suspending current page for process pid %i", m_process->processIdentifier()); 785 auto suspendedPage = std::make_unique<SuspendedPageProxy>(*this, m_process.copyRef(), *fromItem, *mainFrameID); 786 787 LOG(ProcessSwapping, "WebPageProxy %" PRIu64 " created suspended page %s for process pid %i, back/forward item %s" PRIu64, pageID(), suspendedPage->loggingString(), m_process->processIdentifier(), fromItem->itemID().logString()); 776 auto suspendedPage = std::make_unique<SuspendedPageProxy>(*this, m_process.copyRef(), *mainFrameID); 777 778 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); 779 780 if (fromItem && m_preferences->usesPageCache()) 781 fromItem->setSuspendedPage(suspendedPage.get()); 788 782 789 783 m_process->processPool().addSuspendedPage(WTFMove(suspendedPage)); -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r243911 r244075 2357 2357 { 2358 2358 auto it = m_suspendedPages.findIf([&](auto& suspendedPage) { 2359 return suspendedPage-> registrableDomain() == registrableDomain && &suspendedPage->process().websiteDataStore() == &dataStore;2359 return suspendedPage->process().registrableDomain() == registrableDomain && &suspendedPage->process().websiteDataStore() == &dataStore; 2360 2360 }); 2361 2361 if (it == m_suspendedPages.end()) -
trunk/Tools/ChangeLog
r244073 r244075 1 2019-04-09 Chris Dumez <cdumez@apple.com> 2 3 Loads using loadHTMLString() cause flashing when process-swapping 4 https://bugs.webkit.org/show_bug.cgi?id=196714 5 <rdar://problem/49637354> 6 7 Reviewed by Antti Koivisto. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 12 1 13 2019-04-09 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r243961 r244075 2347 2347 { 2348 2348 auto processPoolConfiguration = psonProcessPoolConfiguration(); 2349 processPoolConfiguration.get().usesWebProcessCache = NO; 2349 2350 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 2350 2351 … … 2387 2388 request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main2.html"]]; 2388 2389 [webView loadRequest:request]; 2390 2391 TestWebKitAPI::Util::run(&done); 2392 done = false; 2393 2394 // We should have gone back to the apple.com process for this load since we reuse SuspendedPages' process when possible. 2395 EXPECT_EQ(applePID, [webView _webProcessIdentifier]); 2396 } 2397 2398 TEST(ProcessSwap, ReuseSuspendedProcessLoadHTMLString) 2399 { 2400 auto processPoolConfiguration = psonProcessPoolConfiguration(); 2401 processPoolConfiguration.get().usesWebProcessCache = NO; 2402 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 2403 2404 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 2405 [webViewConfiguration setProcessPool:processPool.get()]; 2406 auto handler = adoptNS([[PSONScheme alloc] init]); 2407 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 2408 2409 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 2410 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 2411 [webView setNavigationDelegate:delegate.get()]; 2412 2413 NSString *htmlString = @"<html><body>TEST</body></html>"; 2414 [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]]; 2415 2416 TestWebKitAPI::Util::run(&done); 2417 done = false; 2418 2419 auto webkitPID = [webView _webProcessIdentifier]; 2420 2421 [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"pson://www.apple.com/main1.html"]]; 2422 2423 TestWebKitAPI::Util::run(&done); 2424 done = false; 2425 2426 auto applePID = [webView _webProcessIdentifier]; 2427 2428 EXPECT_NE(webkitPID, applePID); 2429 2430 [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"pson://www.webkit.org/main2.html"]]; 2431 2432 TestWebKitAPI::Util::run(&done); 2433 done = false; 2434 2435 // We should have gone back to the webkit.org process for this load since we reuse SuspendedPages' process when possible. 2436 EXPECT_EQ(webkitPID, [webView _webProcessIdentifier]); 2437 2438 [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"pson://www.apple.com/main2.html"]]; 2389 2439 2390 2440 TestWebKitAPI::Util::run(&done);
Note:
See TracChangeset
for help on using the changeset viewer.