Changeset 248598 in webkit


Ignore:
Timestamp:
Aug 13, 2019 10:12:43 AM (5 years ago)
Author:
Chris Dumez
Message:

Crash under IPC::Connection::markCurrentlyDispatchedMessageAsInvalid()
https://bugs.webkit.org/show_bug.cgi?id=200674
<rdar://problem/50692748>

Reviewed by Geoff Garen.

Source/WebKit:

When the client terminates a provisional process (e.g. via the [WKWebView _killWebContentProcessAndResetState]
SPI), the WebProcessProxy would notify its associated WebPageProxy objects that it had terminated but would fail
to notify its associated ProvisionalPageProxy objects. As a result, those objects would not get destroyed and
would still think that they were in the middle of a provisional load the next time a load started. This inconsistent
state would lead to crashes such as the one in the radar.

  • UIProcess/ProvisionalPageProxy.cpp:

(WebKit::ProvisionalPageProxy::cancel):

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::requestTermination):

Tools:

Add API test coverage.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248593 r248598  
     12019-08-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under IPC::Connection::markCurrentlyDispatchedMessageAsInvalid()
     4        https://bugs.webkit.org/show_bug.cgi?id=200674
     5        <rdar://problem/50692748>
     6
     7        Reviewed by Geoff Garen.
     8
     9        When the client terminates a provisional process (e.g. via the [WKWebView _killWebContentProcessAndResetState]
     10        SPI), the WebProcessProxy would notify its associated WebPageProxy objects that it had terminated but would fail
     11        to notify its associated ProvisionalPageProxy objects. As a result, those objects would not get destroyed and
     12        would still think that they were in the middle of a provisional load the next time a load started. This inconsistent
     13        state would lead to crashes such as the one in the radar.
     14
     15        * UIProcess/ProvisionalPageProxy.cpp:
     16        (WebKit::ProvisionalPageProxy::cancel):
     17        * UIProcess/WebProcessProxy.cpp:
     18        (WebKit::WebProcessProxy::requestTermination):
     19
    1202019-08-13  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r248585 r248598  
    121121    if (m_provisionalLoadURL.isEmpty())
    122122        return;
     123       
     124    ASSERT(m_process->state() == WebProcessProxy::State::Running);
    123125
    124126    RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "cancel: Simulating a didFailProvisionalLoadForFrame for pageID = %" PRIu64, m_page.pageID().toUInt64());
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r248333 r248598  
    10341034        webConnection()->didClose();
    10351035
     1036    auto provisionalPages = WTF::map(m_provisionalPages, [](auto* provisionalPage) { return makeWeakPtr(provisionalPage); });
    10361037    auto pages = copyToVectorOf<RefPtr<WebPageProxy>>(m_pageMap.values());
    10371038
     
    10401041    for (auto& page : pages)
    10411042        page->processDidTerminate(reason);
     1043       
     1044    for (auto& provisionalPage : provisionalPages) {
     1045        if (provisionalPage)
     1046            provisionalPage->processDidTerminate();
     1047    }
    10421048}
    10431049
  • trunk/Tools/ChangeLog

    r248586 r248598  
     12019-08-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under IPC::Connection::markCurrentlyDispatchedMessageAsInvalid()
     4        https://bugs.webkit.org/show_bug.cgi?id=200674
     5        <rdar://problem/50692748>
     6
     7        Reviewed by Geoff Garen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132019-08-12  Takashi Komori  <Takashi.Komori@sony.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r247073 r248598  
    641641}
    642642
     643TEST(ProcessSwap, KillProvisionalWebContentProcessThenStartNewLoad)
     644{
     645    auto processPoolConfiguration = psonProcessPoolConfiguration();
     646    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     647
     648    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     649    [webViewConfiguration setProcessPool:processPool.get()];
     650    auto handler = adoptNS([[PSONScheme alloc] init]);
     651    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     652
     653    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     654    auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     655    [webView setNavigationDelegate:navigationDelegate.get()];
     656   
     657    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
     658    [webView loadRequest:request];
     659
     660    TestWebKitAPI::Util::run(&done);
     661    done = false;
     662   
     663    // When the provisional load starts in the provisional process, kill the WebView's processes.
     664    navigationDelegate->didStartProvisionalNavigationHandler = ^{
     665        [webView _killWebContentProcessAndResetState];
     666        done = true;
     667    };
     668   
     669    // Start a new cross-site load, which should happen in a new provisional process.
     670    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
     671    [webView loadRequest:request];
     672   
     673    TestWebKitAPI::Util::run(&done);
     674    done = false;
     675   
     676    navigationDelegate->didStartProvisionalNavigationHandler = nil;
     677   
     678    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
     679    [webView loadRequest:request];
     680
     681    TestWebKitAPI::Util::run(&done);
     682    done = false;
     683}
     684
    643685TEST(ProcessSwap, NoSwappingForeTLDPlus2)
    644686{
Note: See TracChangeset for help on using the changeset viewer.