Changeset 242903 in webkit
- Timestamp:
- Mar 13, 2019, 1:32:48 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/loader/FrameLoader.cpp (modified) (7 diffs)
-
Source/WebCore/loader/FrameLoader.h (modified) (2 diffs)
-
Source/WebCore/loader/HistoryController.cpp (modified) (1 diff)
-
Source/WebCore/loader/NavigationAction.cpp (modified) (1 diff)
-
Source/WebCore/loader/NavigationAction.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/NavigationActionData.cpp (modified) (3 diffs)
-
Source/WebKit/Shared/NavigationActionData.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242901 r242903 1 2019-03-13 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(PSON, r240660): Navigation over process boundary is flashy when using Cmd-left/right arrow to navigate 4 https://bugs.webkit.org/show_bug.cgi?id=195684 5 <rdar://problem/48294714> 6 7 Reviewed by Antti Koivisto. 8 9 The issue was caused by us failing to suspend the current page on navigation because the source and 10 target WebBackForwardListItem are identical. The source WebBackForwardListItem was wrong. 11 12 When a navigation is triggered by the WebContent process (and not the UIProcess), we create the Navigation 13 object in WebPageProxy::decidePolicyForNavigationAction(). For the navigation's targetItem, we use the 14 target item identifier provided by the WebContent process via the NavigationActionData. However, 15 for the source item, we would use the WebBackForwardList's currentItem in the UIProcess. The issue 16 is that the WebBackForwardList's currentItem usually has already been updated to be the target 17 item via a WebPageProxy::BackForwardGoToItem() synchronous IPC. 18 19 To avoid raciness and given that the current history management is fragile (as it is managed by 20 both the UIProcess and the WebProcess), I am now passing the source item identifier in 21 addition to the target item identifier in the NavigationActionData that is sent by the WebProcess. 22 This is a lot less error prone, the WebProcess knows more accurately which history items it is going 23 from and to. 24 25 * loader/FrameLoader.cpp: 26 (WebCore::FrameLoader::loadURLIntoChildFrame): 27 (WebCore::FrameLoader::loadDifferentDocumentItem): 28 (WebCore::FrameLoader::loadItem): 29 (WebCore::FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad): 30 * loader/FrameLoader.h: 31 * loader/HistoryController.cpp: 32 (WebCore::HistoryController::recursiveGoToItem): 33 * loader/NavigationAction.cpp: 34 (WebCore::NavigationAction::setSourceBackForwardItem): 35 * loader/NavigationAction.h: 36 (WebCore::NavigationAction::sourceBackForwardItemIdentifier const): 37 1 38 2019-03-13 Jer Noble <jer.noble@apple.com> 2 39 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r242899 r242903 975 975 if (auto* childItem = parentItem->childItemWithTarget(childFrame->tree().uniqueName())) { 976 976 childFrame->loader().m_requestedHistoryItem = childItem; 977 childFrame->loader().loadDifferentDocumentItem(*childItem, loadType(), MayAttemptCacheOnlyLoadForFormSubmissionItem, ShouldTreatAsContinuingLoad::No);977 childFrame->loader().loadDifferentDocumentItem(*childItem, nullptr, loadType(), MayAttemptCacheOnlyLoadForFormSubmissionItem, ShouldTreatAsContinuingLoad::No); 978 978 return; 979 979 } … … 3687 3687 // which should be methods of HistoryController and some of which should be 3688 3688 // methods of FrameLoader. 3689 void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad)3689 void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, HistoryItem* fromItem, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad) 3690 3690 { 3691 3691 RELEASE_LOG_IF_ALLOWED("loadDifferentDocumentItem: frame load started (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); … … 3707 3707 auto action = NavigationAction { *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false }; 3708 3708 action.setTargetBackForwardItem(item); 3709 action.setSourceBackForwardItem(fromItem); 3709 3710 documentLoader->setTriggeringAction(WTFMove(action)); 3710 3711 … … 3797 3798 3798 3799 action.setTargetBackForwardItem(item); 3800 action.setSourceBackForwardItem(fromItem); 3799 3801 3800 3802 loadWithNavigationAction(request, WTFMove(action), LockHistory::No, loadType, { }, AllowNavigationToInvalidURL::Yes); … … 3802 3804 3803 3805 // Loads content into this frame, as specified by history item 3804 void FrameLoader::loadItem(HistoryItem& item, FrameLoadType loadType, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad)3806 void FrameLoader::loadItem(HistoryItem& item, HistoryItem* fromItem, FrameLoadType loadType, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad) 3805 3807 { 3806 3808 m_requestedHistoryItem = &item; … … 3811 3813 loadSameDocumentItem(item); 3812 3814 else 3813 loadDifferentDocumentItem(item, loadType, MayAttemptCacheOnlyLoadForFormSubmissionItem, shouldTreatAsContinuingLoad);3815 loadDifferentDocumentItem(item, fromItem, loadType, MayAttemptCacheOnlyLoadForFormSubmissionItem, shouldTreatAsContinuingLoad); 3814 3816 } 3815 3817 … … 3826 3828 3827 3829 stopAllLoaders(ShouldNotClearProvisionalItem); 3828 loadDifferentDocumentItem(item, loadType, MayNotAttemptCacheOnlyLoadForFormSubmissionItem, ShouldTreatAsContinuingLoad::No);3830 loadDifferentDocumentItem(item, history().currentItem(), loadType, MayNotAttemptCacheOnlyLoadForFormSubmissionItem, ShouldTreatAsContinuingLoad::No); 3829 3831 } 3830 3832 -
trunk/Source/WebCore/loader/FrameLoader.h
r241480 r242903 134 134 135 135 void open(CachedFrameBase&); 136 void loadItem(HistoryItem&, FrameLoadType, ShouldTreatAsContinuingLoad);136 void loadItem(HistoryItem&, HistoryItem* fromItem, FrameLoadType, ShouldTreatAsContinuingLoad); 137 137 HistoryItem* requestedHistoryItem() const { return m_requestedHistoryItem.get(); } 138 138 … … 336 336 337 337 void loadSameDocumentItem(HistoryItem&); 338 void loadDifferentDocumentItem(HistoryItem&, FrameLoadType, FormSubmissionCacheLoadPolicy, ShouldTreatAsContinuingLoad);338 void loadDifferentDocumentItem(HistoryItem&, HistoryItem* fromItem, FrameLoadType, FormSubmissionCacheLoadPolicy, ShouldTreatAsContinuingLoad); 339 339 340 340 void loadProvisionalItemFromCachedPage(); -
trunk/Source/WebCore/loader/HistoryController.cpp
r239720 r242903 752 752 { 753 753 if (!itemsAreClones(item, fromItem)) { 754 m_frame.loader().loadItem(item, type, shouldTreatAsContinuingLoad);754 m_frame.loader().loadItem(item, fromItem, type, shouldTreatAsContinuingLoad); 755 755 return; 756 756 } -
trunk/Source/WebCore/loader/NavigationAction.cpp
r239461 r242903 145 145 } 146 146 147 void NavigationAction::setSourceBackForwardItem(HistoryItem* item) 148 { 149 m_sourceBackForwardItemIdentifier = item ? makeOptional(item->identifier()) : WTF::nullopt; 147 150 } 151 152 } -
trunk/Source/WebCore/loader/NavigationAction.h
r241451 r242903 130 130 const Optional<BackForwardItemIdentifier>& targetBackForwardItemIdentifier() const { return m_targetBackForwardItemIdentifier; } 131 131 132 void setSourceBackForwardItem(HistoryItem*); 133 const Optional<BackForwardItemIdentifier>& sourceBackForwardItemIdentifier() const { return m_sourceBackForwardItemIdentifier; } 134 132 135 LockHistory lockHistory() const { return m_lockHistory; } 133 136 void setLockHistory(LockHistory lockHistory) { m_lockHistory = lockHistory; } … … 155 158 bool m_openedByDOMWithOpener { false }; 156 159 Optional<BackForwardItemIdentifier> m_targetBackForwardItemIdentifier; 160 Optional<BackForwardItemIdentifier> m_sourceBackForwardItemIdentifier; 157 161 LockHistory m_lockHistory { LockHistory::No }; 158 162 LockBackForwardList m_lockBackForwardList { LockBackForwardList::No }; -
trunk/Source/WebKit/ChangeLog
r242899 r242903 1 2019-03-13 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(PSON, r240660): Navigation over process boundary is flashy when using Cmd-left/right arrow to navigate 4 https://bugs.webkit.org/show_bug.cgi?id=195684 5 <rdar://problem/48294714> 6 7 Reviewed by Antti Koivisto. 8 9 * Shared/NavigationActionData.cpp: 10 (WebKit::NavigationActionData::encode const): 11 (WebKit::NavigationActionData::decode): 12 * Shared/NavigationActionData.h: 13 * UIProcess/WebPageProxy.cpp: 14 (WebKit::WebPageProxy::decidePolicyForNavigationAction): 15 (WebKit::WebPageProxy::backForwardAddItem): 16 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 17 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): 18 1 19 2019-03-13 Chris Dumez <cdumez@apple.com> 2 20 -
trunk/Source/WebKit/Shared/NavigationActionData.cpp
r241049 r242903 51 51 encoder << requesterOrigin; 52 52 encoder << targetBackForwardItemIdentifier; 53 encoder << sourceBackForwardItemIdentifier; 53 54 encoder.encodeEnum(lockHistory); 54 55 encoder.encodeEnum(lockBackForwardList); … … 128 129 return WTF::nullopt; 129 130 131 Optional<Optional<WebCore::BackForwardItemIdentifier>> sourceBackForwardItemIdentifier; 132 decoder >> sourceBackForwardItemIdentifier; 133 if (!sourceBackForwardItemIdentifier) 134 return WTF::nullopt; 135 130 136 WebCore::LockHistory lockHistory; 131 137 if (!decoder.decodeEnum(lockHistory)) … … 149 155 WTFMove(*canHandleRequest), WTFMove(shouldOpenExternalURLsPolicy), WTFMove(*downloadAttribute), WTFMove(clickLocationInRootViewCoordinates), 150 156 WTFMove(*isRedirect), *treatAsSameOriginNavigation, *hasOpenedFrames, *openedByDOMWithOpener, WTFMove(*requesterOrigin), 151 WTFMove(*targetBackForwardItemIdentifier), lockHistory, lockBackForwardList, WTFMove(*clientRedirectSourceForHistory), WTFMove(*adClickAttribution) }};157 WTFMove(*targetBackForwardItemIdentifier), WTFMove(*sourceBackForwardItemIdentifier), lockHistory, lockBackForwardList, WTFMove(*clientRedirectSourceForHistory), WTFMove(*adClickAttribution) }}; 152 158 } 153 159 -
trunk/Source/WebKit/Shared/NavigationActionData.h
r241049 r242903 59 59 WebCore::SecurityOriginData requesterOrigin; 60 60 Optional<WebCore::BackForwardItemIdentifier> targetBackForwardItemIdentifier; 61 Optional<WebCore::BackForwardItemIdentifier> sourceBackForwardItemIdentifier; 61 62 WebCore::LockHistory lockHistory; 62 63 WebCore::LockBackForwardList lockBackForwardList; -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r242840 r242903 4516 4516 if (!navigation) { 4517 4517 if (auto targetBackForwardItemIdentifier = navigationActionData.targetBackForwardItemIdentifier) { 4518 if (auto* item = m_backForwardList->itemForID(*targetBackForwardItemIdentifier)) 4519 navigation = m_navigationState->createBackForwardNavigation(*item, m_backForwardList->currentItem(), FrameLoadType::IndexedBackForward); 4518 if (auto* item = m_backForwardList->itemForID(*targetBackForwardItemIdentifier)) { 4519 auto* fromItem = navigationActionData.sourceBackForwardItemIdentifier ? m_backForwardList->itemForID(*navigationActionData.sourceBackForwardItemIdentifier) : nullptr; 4520 if (!fromItem) 4521 fromItem = m_backForwardList->currentItem(); 4522 WTFLogAlways("WebPageProxy::decidePolicyForNavigationAction() creates back/forward navigation from item %s", fromItem ? fromItem->url().utf8().data() : "null"); 4523 navigation = m_navigationState->createBackForwardNavigation(*item, fromItem, FrameLoadType::IndexedBackForward); 4524 } 4520 4525 } 4521 4526 if (!navigation) … … 5580 5585 void WebPageProxy::backForwardAddItem(BackForwardListItemState&& itemState) 5581 5586 { 5582 m_backForwardList->addItem(WebBackForwardListItem::create(WTFMove(itemState), pageID())); 5587 auto item = WebBackForwardListItem::create(WTFMove(itemState), pageID()); 5588 m_backForwardList->addItem(WTFMove(item)); 5583 5589 } 5584 5590 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r242899 r242903 881 881 navigationActionData.requesterOrigin = requester->securityOrigin().data(); 882 882 navigationActionData.targetBackForwardItemIdentifier = navigationAction.targetBackForwardItemIdentifier(); 883 navigationActionData.sourceBackForwardItemIdentifier = navigationAction.sourceBackForwardItemIdentifier(); 883 884 navigationActionData.lockHistory = navigationAction.lockHistory(); 884 885 navigationActionData.lockBackForwardList = navigationAction.lockBackForwardList(); -
trunk/Tools/ChangeLog
r242885 r242903 1 2019-03-13 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION(PSON, r240660): Navigation over process boundary is flashy when using Cmd-left/right arrow to navigate 4 https://bugs.webkit.org/show_bug.cgi?id=195684 5 <rdar://problem/48294714> 6 7 Reviewed by Antti Koivisto. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 12 1 13 2019-03-13 Aakash Jain <aakash_jain@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r242755 r242903 3138 3138 } 3139 3139 3140 TEST(ProcessSwap, PageCacheWhenNavigatingFromJS) 3141 { 3142 auto processPoolConfiguration = psonProcessPoolConfiguration(); 3143 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 3144 3145 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 3146 [webViewConfiguration setProcessPool:processPool.get()]; 3147 auto handler = adoptNS([[PSONScheme alloc] init]); 3148 [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:pageCache1Bytes]; 3149 [handler addMappingFromURLString:@"pson://www.apple.com/main.html" toData:pageCache1Bytes]; 3150 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 3151 3152 auto messageHandler = adoptNS([[PSONMessageHandler alloc] init]); 3153 [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"]; 3154 3155 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 3156 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 3157 [webView setNavigationDelegate:delegate.get()]; 3158 3159 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]; 3160 3161 [webView loadRequest:request]; 3162 TestWebKitAPI::Util::run(&done); 3163 done = false; 3164 3165 auto pidAfterLoad1 = [webView _webProcessIdentifier]; 3166 3167 EXPECT_EQ(1u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3168 3169 request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]]; 3170 3171 [webView loadRequest:request]; 3172 TestWebKitAPI::Util::run(&done); 3173 done = false; 3174 3175 auto pidAfterLoad2 = [webView _webProcessIdentifier]; 3176 3177 EXPECT_EQ(2u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3178 EXPECT_NE(pidAfterLoad1, pidAfterLoad2); 3179 3180 [webView evaluateJavaScript:@"history.back()" completionHandler: nil]; 3181 TestWebKitAPI::Util::run(&receivedMessage); 3182 receivedMessage = false; 3183 TestWebKitAPI::Util::run(&done); 3184 done = false; 3185 3186 auto pidAfterLoad3 = [webView _webProcessIdentifier]; 3187 3188 EXPECT_EQ(2u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3189 EXPECT_EQ(pidAfterLoad1, pidAfterLoad3); 3190 EXPECT_EQ(1u, [receivedMessages count]); 3191 EXPECT_TRUE([receivedMessages.get()[0] isEqualToString:@"Was persisted" ]); 3192 EXPECT_EQ(2u, seenPIDs.size()); 3193 3194 [webView evaluateJavaScript:@"history.forward()" completionHandler: nil]; 3195 TestWebKitAPI::Util::run(&receivedMessage); 3196 receivedMessage = false; 3197 TestWebKitAPI::Util::run(&done); 3198 done = false; 3199 3200 auto pidAfterLoad4 = [webView _webProcessIdentifier]; 3201 3202 EXPECT_EQ(2u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3203 EXPECT_EQ(pidAfterLoad2, pidAfterLoad4); 3204 EXPECT_EQ(2u, [receivedMessages count]); 3205 EXPECT_TRUE([receivedMessages.get()[1] isEqualToString:@"Was persisted" ]); 3206 EXPECT_EQ(2u, seenPIDs.size()); 3207 } 3208 3140 3209 TEST(ProcessSwap, NumberOfPrewarmedProcesses) 3141 3210 {
Note:
See TracChangeset
for help on using the changeset viewer.