Changeset 259209 in webkit


Ignore:
Timestamp:
Mar 30, 2020 10:35:11 AM (4 years ago)
Author:
Chris Dumez
Message:

Regression(r246188) WebProcess is launched too eagerly when [WKWebView _restoreSessionState] is called
https://bugs.webkit.org/show_bug.cgi?id=207908
<rdar://problem/59619323>

Reviewed by Darin Adler.

Since r246188, the WebProcess is launched eagerly when [WKWebView _restoreSessionState] is called. This is bad
for performance because we are unable to leverage the process cache at this point (since we don't know which
domain will be loaded).

This patch thus reverts r246188 and fixes what r246188 was trying to address in a different way. If the process
was not launched yet when restoreSessionState() is called, the session state properly gets sent to the WebProcess
after launch, via the WebPageCreationParameters. What was missing at that point was that the session state was
restore by an API Request. To fix this, we now pass an extra itemStatesWereRestoredByAPIRequest flag in
WebPageCreationParameters.

  • Shared/WebPageCreationParameters.cpp:

(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):

  • Shared/WebPageCreationParameters.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::restoreFromSessionState):

  • UIProcess/WebPageProxy.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::m_processDisplayName):

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259207 r259209  
     12020-03-30  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r246188) WebProcess is launched too eagerly when [WKWebView _restoreSessionState] is called
     4        https://bugs.webkit.org/show_bug.cgi?id=207908
     5        <rdar://problem/59619323>
     6
     7        Reviewed by Darin Adler.
     8
     9        Since r246188, the WebProcess is launched eagerly when [WKWebView _restoreSessionState] is called. This is bad
     10        for performance because we are unable to leverage the process cache at this point (since we don't know which
     11        domain will be loaded).
     12
     13        This patch thus reverts r246188 and fixes what r246188 was trying to address in a different way. If the process
     14        was not launched yet when restoreSessionState() is called, the session state properly gets sent to the WebProcess
     15        after launch, via the WebPageCreationParameters. What was missing at that point was that the session state was
     16        restore by an API Request. To fix this, we now pass an extra itemStatesWereRestoredByAPIRequest flag in
     17        WebPageCreationParameters.
     18
     19        * Shared/WebPageCreationParameters.cpp:
     20        (WebKit::WebPageCreationParameters::encode const):
     21        (WebKit::WebPageCreationParameters::decode):
     22        * Shared/WebPageCreationParameters.h:
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::WebPageProxy::restoreFromSessionState):
     25        * UIProcess/WebPageProxy.h:
     26        * WebProcess/WebPage/WebPage.cpp:
     27        (WebKit::m_processDisplayName):
     28
    1292020-03-30  Wenson Hsieh  <wenson_hsieh@apple.com>
    230
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp

    r259187 r259209  
    5353    encoder << paginationLineGridEnabled;
    5454    encoder << userAgent;
     55    encoder << itemStatesWereRestoredByAPIRequest;
    5556    encoder << itemStates;
    5657    encoder << userContentControllerID;
     
    212213    parameters.userAgent = WTFMove(*userAgent);
    213214
     215    Optional<bool> itemStatesWereRestoredByAPIRequest;
     216    decoder >> itemStatesWereRestoredByAPIRequest;
     217    if (!itemStatesWereRestoredByAPIRequest)
     218        return WTF::nullopt;
     219    parameters.itemStatesWereRestoredByAPIRequest = *itemStatesWereRestoredByAPIRequest;
     220
    214221    Optional<Vector<BackForwardListItemState>> itemStates;
    215222    decoder >> itemStates;
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.h

    r259187 r259209  
    9898    String userAgent;
    9999
     100    bool itemStatesWereRestoredByAPIRequest { false };
    100101    Vector<BackForwardListItemState> itemStates;
    101102
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r259187 r259209  
    34993499
    35003500    if (hasBackForwardList) {
    3501         // If there isn't a running process yet the RestoreSession message below is just ignored, and
    3502         // session is restored when the web process is created via creation parameters which is not
    3503         // considered an API request. So, we launch the initial process here before restoring the
    3504         // session to ensure the session is restored in the web process via RestoreSession IPC message
    3505         // which is considered an API request. See https://bugs.webkit.org/show_bug.cgi?id=198561.
    3506         launchInitialProcessIfNecessary();
     3501        m_sessionStateWasRestoredByAPIRequest = true;
    35073502
    35083503        m_backForwardList->restoreFromState(WTFMove(sessionState.backForwardListState));
    3509         send(Messages::WebPage::RestoreSession(m_backForwardList->itemStates()));
     3504        // If the process is not launched yet, the session will be restored when sending the WebPageCreationParameters;
     3505        if (hasRunningProcess())
     3506            send(Messages::WebPage::RestoreSession(m_backForwardList->itemStates()));
    35103507
    35113508        auto transaction = m_pageLoadState.transaction();
     
    76857682    parameters.paginationLineGridEnabled = m_paginationLineGridEnabled;
    76867683    parameters.userAgent = userAgent();
     7684    parameters.itemStatesWereRestoredByAPIRequest = m_sessionStateWasRestoredByAPIRequest;
    76877685    parameters.itemStates = m_backForwardList->itemStates();
    76887686    parameters.userContentControllerID = m_userContentController->identifier();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r259187 r259209  
    27522752    COMPtr<ID3D11Device1> m_device;
    27532753#endif
     2754    bool m_sessionStateWasRestoredByAPIRequest { false };
    27542755    bool m_isQuotaIncreaseDenied { false };
    27552756    bool m_isLayerTreeFrozenDueToSwipeAnimation { false };
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r259187 r259209  
    649649   
    650650    if (!parameters.itemStates.isEmpty())
    651         restoreSessionInternal(parameters.itemStates, WasRestoredByAPIRequest::No, WebBackForwardListProxy::OverwriteExistingItem::Yes);
     651        restoreSessionInternal(parameters.itemStates, parameters.itemStatesWereRestoredByAPIRequest ? WasRestoredByAPIRequest::Yes : WasRestoredByAPIRequest::No, WebBackForwardListProxy::OverwriteExistingItem::Yes);
    652652
    653653    m_drawingArea->enablePainting();
Note: See TracChangeset for help on using the changeset viewer.