⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244799 in webkit


Ignore:
Timestamp:
Apr 30, 2019, 1:20:00 PM (7 years ago)
Author:
Chris Dumez
Message:

Only use a related page's process if that page has not been closed yet
https://bugs.webkit.org/show_bug.cgi?id=197393
<rdar://problem/50302423>

Reviewed by Tim Horton.

Source/WebKit:

We should not attempt to use a related page's process if that related page has already been closed.
Once closed, a page's process is invalid and trying to launch a new process for the closed page
leads to crashes such as the one in the radar.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::launchProcess):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::createWebPage):

Tools:

Add API test coverage.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244781 r244799  
     12019-04-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Only use a related page's process if that page has not been closed yet
     4        https://bugs.webkit.org/show_bug.cgi?id=197393
     5        <rdar://problem/50302423>
     6
     7        Reviewed by Tim Horton.
     8
     9        We should not attempt to use a related page's process if that related page has already been closed.
     10        Once closed, a page's process is invalid and trying to launch a new process for the closed page
     11        leads to crashes such as the one in the radar.
     12
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::launchProcess):
     15        * UIProcess/WebProcessPool.cpp:
     16        (WebKit::WebProcessPool::createWebPage):
     17
    1182019-04-30  Tim Horton  <timothy_horton@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r244670 r244799  
    728728    auto& processPool = m_process->processPool();
    729729
    730     if (auto* relatedPage = m_configuration->relatedPage())
     730    auto* relatedPage = m_configuration->relatedPage();
     731    if (relatedPage && !relatedPage->isClosed())
    731732        m_process = relatedPage->ensureRunningProcess();
    732733    else
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r244521 r244799  
    12111211
    12121212    RefPtr<WebProcessProxy> process;
    1213     if (pageConfiguration->relatedPage()) {
     1213    auto* relatedPage = pageConfiguration->relatedPage();
     1214    if (relatedPage && !relatedPage->isClosed()) {
    12141215        // Sharing processes, e.g. when creating the page via window.open().
    12151216        process = &pageConfiguration->relatedPage()->ensureRunningProcess();
  • trunk/Tools/ChangeLog

    r244792 r244799  
     12019-04-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Only use a related page's process if that page has not been closed yet
     4        https://bugs.webkit.org/show_bug.cgi?id=197393
     5        <rdar://problem/50302423>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132019-04-30  Aakash Jain  <aakash_jain@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r244613 r244799  
    47104710}
    47114711
     4712TEST(ProcessSwap, ReloadRelatedWebViewAfterCrash)
     4713{
     4714    auto processPoolConfiguration = psonProcessPoolConfiguration();
     4715    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     4716
     4717    auto webView1Configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     4718    [webView1Configuration setProcessPool:processPool.get()];
     4719    auto handler = adoptNS([[PSONScheme alloc] init]);
     4720    [webView1Configuration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     4721
     4722    auto webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webView1Configuration.get()]);
     4723    auto delegate = adoptNS([[TestNavigationDelegate alloc] init]);
     4724    __block bool didCrash = false;
     4725    [delegate setWebContentProcessDidTerminate:^(WKWebView *view) {
     4726        [view reload];
     4727        didCrash = true;
     4728    }];
     4729    [delegate setDidFinishNavigation:^(WKWebView *, WKNavigation *) {
     4730        done = true;
     4731    }];
     4732
     4733    [webView1 setNavigationDelegate:delegate.get()];
     4734
     4735    auto webView2Configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     4736    [webView2Configuration setProcessPool:processPool.get()];
     4737    [webView2Configuration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     4738    webView2Configuration.get()._relatedWebView = webView1.get(); // webView2 will be related to webView1 and webView1's URL will be used for process swap decision.
     4739    auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webView2Configuration.get()]);
     4740    [webView2 setNavigationDelegate:delegate.get()];
     4741
     4742    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     4743    [webView1 loadRequest:request];
     4744
     4745    TestWebKitAPI::Util::run(&done);
     4746    done = false;
     4747
     4748    auto pid1 = [webView1 _webProcessIdentifier];
     4749
     4750    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main2.html"]];
     4751    [webView2 loadRequest:request];
     4752
     4753    TestWebKitAPI::Util::run(&done);
     4754    done = false;
     4755
     4756    auto pid2 = [webView2 _webProcessIdentifier];
     4757
     4758    EXPECT_EQ(pid1, pid2); // WebViews are related so they should share the same process.
     4759
     4760    [webView1 _close];
     4761    webView1 = nullptr;
     4762
     4763    kill(pid1, 9);
     4764
     4765    TestWebKitAPI::Util::run(&didCrash);
     4766    didCrash = false;
     4767
     4768    TestWebKitAPI::Util::run(&done);
     4769    done = false;
     4770}
     4771
    47124772TEST(ProcessSwap, TerminatedSuspendedPageProcess)
    47134773{
Note: See TracChangeset for help on using the changeset viewer.