Bug 192668 - [PSON] We should not need to navigate to 'about:blank' to suspend pages
Summary: [PSON] We should not need to navigate to 'about:blank' to suspend pages
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on: 192772 193224
Blocks:
  Show dependency treegraph
 
Reported: 2018-12-13 10:09 PST by Chris Dumez
Modified: 2019-01-07 16:52 PST (History)
10 users (show)

See Also:


Attachments
WIP Patch (16.31 KB, patch)
2018-12-13 10:54 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (27.70 KB, patch)
2018-12-13 12:33 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (31.59 KB, patch)
2018-12-13 13:58 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2018-12-13 10:09:37 PST
We should not need to navigate to 'about:blank' to suspend pages to support PageCache when PSON is enabled.
Comment 1 Radar WebKit Bug Importer 2018-12-13 10:35:56 PST
<rdar://problem/46701466>
Comment 2 Chris Dumez 2018-12-13 10:54:45 PST
Created attachment 357238 [details]
WIP Patch
Comment 3 EWS Watchlist 2018-12-13 10:56:46 PST
Attachment 357238 [details] did not pass style-queue:


ERROR: Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp:53:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WebKit/WebProcess/WebPage/WebPage.cpp:1333:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 2 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Chris Dumez 2018-12-13 12:33:32 PST
Created attachment 357244 [details]
Patch
Comment 5 Chris Dumez 2018-12-13 13:58:00 PST
Created attachment 357251 [details]
Patch
Comment 6 WebKit Commit Bot 2018-12-13 15:17:53 PST
Comment on attachment 357251 [details]
Patch

Clearing flags on attachment: 357251

Committed r239182: <https://trac.webkit.org/changeset/239182>
Comment 7 WebKit Commit Bot 2018-12-13 15:17:54 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Antti Koivisto 2018-12-14 05:18:33 PST
Comment on attachment 357251 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=357251&action=review

Nice!

> Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:-739
> -    if (request.url() == WTF::blankURL() && webPage->isSuspended()) {

Does isSuspended bit on WebPage have any clients after this? Maybe it is not even needed anymore?

> Source/WebKit/WebProcess/WebPage/WebPage.cpp:1331
> +    if (!PageCache::singleton().addIfCacheable(*currentHistoryItem, corePage())) {
> +        failedToSuspend();
> +        return;
> +    }

So this leaves us in a new type of state where we the current page is moved to page cache but we haven't navigated anywhere. I suppose that is ok.

Does failedToSuspend() throws away the process? Could we just close the page when caching fails but keep the process around (since it has useful caches etc for back navigation)?
Comment 9 Chris Dumez 2018-12-14 08:43:23 PST
(In reply to Antti Koivisto from comment #8)
> Comment on attachment 357251 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=357251&action=review
> 
> Nice!
> 
> > Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:-739
> > -    if (request.url() == WTF::blankURL() && webPage->isSuspended()) {
> 
> Does isSuspended bit on WebPage have any clients after this? Maybe it is not
> even needed anymore?

There is still one call site:
bool WebProcess::hasPageRequiringPageCacheWhileSuspended() const
{
    for (auto& page : m_pageMap.values()) {
        if (page->isSuspended())
            return true;
    }
    return false;
}

We need to know a page is suspended for process-swap when the process actually gets suspended on iOS to avoid clearing the PageCache.

> 
> > Source/WebKit/WebProcess/WebPage/WebPage.cpp:1331
> > +    if (!PageCache::singleton().addIfCacheable(*currentHistoryItem, corePage())) {
> > +        failedToSuspend();
> > +        return;
> > +    }
> 
> So this leaves us in a new type of state where we the current page is moved
> to page cache but we haven't navigated anywhere. I suppose that is ok.

Yes, it is kind of a new state but it seems to work OK, and navigating to the current history item works fine too and restores it from PageCache.

> 
> Does failedToSuspend() throws away the process? Could we just close the page
> when caching fails but keep the process around (since it has useful caches
> etc for back navigation)?

Yes, I am not keeping the process around anymore if page cache fails. I have discussed this with Brady and Geoff as well.
If it turns out to be an issue, then we can do better and cache processes. It is not quite as easy as it sounds though because
if you re-attach to a process that used to have a WebPage with your ID, you may get leftover IPC from the previous page when
you reconnect and it would trigger MESSAGE_CHECK failures in the UIProcess. So we'd still need some kind of handshake like
Close -> DoneClosing before we would be able to reuse the process.
Comment 10 Antti Koivisto 2018-12-14 12:08:51 PST
> Yes, I am not keeping the process around anymore if page cache fails. I have
> discussed this with Brady and Geoff as well.
> If it turns out to be an issue, then we can do better and cache processes.
> It is not quite as easy as it sounds though because
> if you re-attach to a process that used to have a WebPage with your ID, you
> may get leftover IPC from the previous page when
> you reconnect and it would trigger MESSAGE_CHECK failures in the UIProcess.
> So we'd still need some kind of handshake like
> Close -> DoneClosing before we would be able to reuse the process.

Makes sense. A suspended page is always in this specific page cache-like state. A hypothetical per-domain process cache would handle other cases.