Changeset 238565 in webkit


Ignore:
Timestamp:
Nov 27, 2018 11:52:36 AM (5 years ago)
Author:
Chris Dumez
Message:

Regression(PSON) crash under WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame()
https://bugs.webkit.org/show_bug.cgi?id=191983
<rdar://problem/46246863>

Reviewed by Geoffrey Garen.

Source/WebKit:

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::continueNavigationInNewProcess):
Make sure the navigation still exists in m_mainFrameCreationHandler and return early if it
does not.

(WebKit::WebPageProxy::resetState):
Clear out m_mainFrameCreationHandler / m_mainFrameWindowCreationHandler if we resetting the state
after a crash. At this point, there is no chance the WebProcess will send us the IPC that will
cause these to get called and we do not want old state to remain for future navigations.

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238562 r238565  
     12018-11-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(PSON) crash under WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame()
     4        https://bugs.webkit.org/show_bug.cgi?id=191983
     5        <rdar://problem/46246863>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * UIProcess/WebPageProxy.cpp:
     10        (WebKit::WebPageProxy::continueNavigationInNewProcess):
     11        Make sure the navigation still exists in m_mainFrameCreationHandler and return early if it
     12        does not.
     13
     14        (WebKit::WebPageProxy::resetState):
     15        Clear out m_mainFrameCreationHandler / m_mainFrameWindowCreationHandler if we resetting the state
     16        after a crash. At this point, there is no chance the WebProcess will send us the IPC that will
     17        cause these to get called and we do not want old state to remain for future navigations.
     18
    1192018-11-16  Jiewen Tan  <jiewen_tan@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r238562 r238565  
    27052705
    27062706        ASSERT(!m_mainFrame);
    2707         m_mainFrameCreationHandler = [this, protectedThis = WTFMove(protectedThis), navigation = navigation.copyRef(), request =  navigation->currentRequest(), mainFrameURL, isServerRedirect = navigation->currentRequestIsRedirect()]() mutable {
     2707        m_mainFrameCreationHandler = [this, protectedThis = WTFMove(protectedThis), navigationID = navigation->navigationID(), request =  navigation->currentRequest(), mainFrameURL, isServerRedirect = navigation->currentRequestIsRedirect()]() mutable {
    27082708            ASSERT(m_mainFrame);
     2709            // This navigation was destroyed so no need to notify of redirect.
     2710            if (!navigationState().navigation(navigationID))
     2711                return;
     2712
    27092713            // Restore the main frame's committed URL as some clients may rely on it until the next load is committed.
    27102714            m_mainFrame->frameLoadState().setURL(mainFrameURL);
     
    27152719            if (isServerRedirect) {
    27162720                m_mainFrame->frameLoadState().didStartProvisionalLoad(request.url());
    2717                 didReceiveServerRedirectForProvisionalLoadForFrame(m_mainFrame->frameID(), navigation->navigationID(), WTFMove(request), { });
     2721                didReceiveServerRedirectForProvisionalLoadForFrame(m_mainFrame->frameID(), navigationID, WTFMove(request), { });
    27182722            }
    27192723        };
     
    62656269{
    62666270    m_mainFrame = nullptr;
     6271    m_mainFrameCreationHandler = nullptr;
     6272    m_mainFrameWindowCreationHandler = nullptr;
     6273
    62676274#if PLATFORM(COCOA)
    62686275    m_scrollingPerformanceData = nullptr;
  • trunk/Tools/ChangeLog

    r238548 r238565  
     12018-11-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(PSON) crash under WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame()
     4        https://bugs.webkit.org/show_bug.cgi?id=191983
     5        <rdar://problem/46246863>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132018-11-27  Aakash Jain  <aakash_jain@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r238456 r238565  
    486486}
    487487
     488TEST(ProcessSwap, KillWebContentProcessAfterServerRedirectPolicyDecision)
     489{
     490    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     491    processPoolConfiguration.get().processSwapsOnNavigation = YES;
     492    processPoolConfiguration.get().prewarmsProcessesAutomatically = YES;
     493    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     494
     495    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     496    [webViewConfiguration setProcessPool:processPool.get()];
     497    auto handler = adoptNS([[PSONScheme alloc] init]);
     498    [handler addRedirectFromURLString:@"pson://www.webkit.org/main2.html" toURLString:@"pson://www.apple.com/main.html"];
     499    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     500
     501    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     502    auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     503    [webView setNavigationDelegate:navigationDelegate.get()];
     504
     505    [webView configuration].preferences.safeBrowsingEnabled = NO;
     506
     507    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     508    [webView loadRequest:request];
     509
     510    TestWebKitAPI::Util::run(&done);
     511    done = false;
     512
     513    __block BOOL isRedirection = NO;
     514    navigationDelegate->decidePolicyForNavigationAction = ^(WKNavigationAction * action, void (^decisionHandler)(WKNavigationActionPolicy)) {
     515        decisionHandler(WKNavigationActionPolicyAllow);
     516        if (!isRedirection) {
     517            isRedirection = YES;
     518            return;
     519        }
     520
     521        navigationDelegate->decidePolicyForNavigationAction = nil;
     522        [webView _killWebContentProcessAndResetState];
     523        done = true;
     524    };
     525
     526    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main2.html"]];
     527    [webView loadRequest:request];
     528
     529    TestWebKitAPI::Util::run(&done);
     530    done = false;
     531
     532    TestWebKitAPI::Util::spinRunLoop(10);
     533    [webView reload];
     534
     535    TestWebKitAPI::Util::run(&done);
     536    done = false;
     537}
     538
    488539TEST(ProcessSwap, NoSwappingForeTLDPlus2)
    489540{
Note: See TracChangeset for help on using the changeset viewer.