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

Changeset 285877 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 11:55:35 AM (5 years ago)
Author:
Chris Dumez
Message:

Crash under WebKit::WebPageProxy::commitProvisionalPage()
https://bugs.webkit.org/show_bug.cgi?id=233199
<rdar://57659921>

Reviewed by Youenn Fablet.

Source/WebKit:

In the event where the committed WebProcess would crash while a cross-site provisional load
is going on in a provisional page / WebProcess, we would do a null dereference of the page's
drawing area when trying to commit the provisional page later on. We would also hit various
assertions in debug since the page's state gets completely reset when its WebProcess crashes.

To address the issue, we now clear the provisional page if the page's WebProcess crashes.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::resetStateAfterProcessExited):

Tools:

Add API test coverage.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285873 r285877  
     12021-11-16  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under WebKit::WebPageProxy::commitProvisionalPage()
     4        https://bugs.webkit.org/show_bug.cgi?id=233199
     5        <rdar://57659921>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        In the event where the committed WebProcess would crash while a cross-site provisional load
     10        is going on in a provisional page / WebProcess, we would do a null dereference of the page's
     11        drawing area when trying to commit the provisional page later on. We would also hit various
     12        assertions in debug since the page's state gets completely reset when its WebProcess crashes.
     13
     14        To address the issue, we now clear the provisional page if the page's WebProcess crashes.
     15
     16        * UIProcess/WebPageProxy.cpp:
     17        (WebKit::WebPageProxy::resetStateAfterProcessExited):
     18
    1192021-11-16  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r285694 r285877  
    79377937    m_cachedFontAttributesAtSelectionStart.reset();
    79387938
     7939    if (terminationReason != ProcessTerminationReason::NavigationSwap)
     7940        m_provisionalPage = nullptr;
     7941
    79397942    if (terminationReason == ProcessTerminationReason::NavigationSwap)
    79407943        pageClient().processWillSwap();
  • trunk/Tools/ChangeLog

    r285876 r285877  
     12021-11-16  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under WebKit::WebPageProxy::commitProvisionalPage()
     4        https://bugs.webkit.org/show_bug.cgi?id=233199
     5        <rdar://57659921>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132021-11-16  Fujii Hironori  <Hironori.Fujii@sony.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r285873 r285877  
    55265526    EXPECT_NE(pid1, pid4);
    55275527    EXPECT_NE(pid3, pid4);
     5528}
     5529
     5530TEST(ProcessSwap, CommittedProcessCrashDuringCrossSiteNavigation)
     5531{
     5532    auto processPoolConfiguration = psonProcessPoolConfiguration();
     5533    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     5534
     5535    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     5536    [webViewConfiguration setProcessPool:processPool.get()];
     5537    auto handler = adoptNS([[PSONScheme alloc] init]);
     5538    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     5539
     5540    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     5541    auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     5542    [webView setNavigationDelegate:navigationDelegate.get()];
     5543
     5544    done = false;
     5545    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
     5546    [webView loadRequest:request];
     5547
     5548    TestWebKitAPI::Util::run(&done);
     5549    done = false;
     5550
     5551    auto pid1 = [webView _webProcessIdentifier];
     5552
     5553    static bool didKill = false;
     5554    navigationDelegate->decidePolicyForNavigationAction = ^(WKNavigationAction *, void (^decisionHandler)(WKNavigationActionPolicy)) {
     5555        decisionHandler(WKNavigationActionPolicyAllow); // Will ask the load to proceed in a new provisional WebProcess since the navigation is cross-site.
     5556
     5557        // Simulate a crash of the committed WebProcess while the provisional navigation starts in the new provisional WebProcess.
     5558        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
     5559            kill(pid1, 9);
     5560            didKill = true;
     5561        });
     5562    };
     5563
     5564    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
     5565    [webView loadRequest:request];
     5566
     5567    TestWebKitAPI::Util::run(&didKill);
     5568
     5569    TestWebKitAPI::Util::sleep(0.5);
    55285570}
    55295571
Note: See TracChangeset for help on using the changeset viewer.