Changeset 239182 in webkit


Ignore:
Timestamp:
Dec 13, 2018 3:17:44 PM (5 years ago)
Author:
Chris Dumez
Message:

[PSON] We should not need to navigate to 'about:blank' to suspend pages
https://bugs.webkit.org/show_bug.cgi?id=192668
<rdar://problem/46701466>

Reviewed by Alex Christensen.

Source/WebCore:

  • history/PageCache.cpp:

(WebCore::PageCache::addIfCacheable):

  • history/PageCache.h:
  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::redirectReceived):
(WebCore::DocumentLoader::willSendRequest):
(WebCore::DocumentLoader::startLoadingMainResource):

  • loader/DocumentLoader.h:
  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::init):
(WebCore::FrameLoader::stopAllLoaders):
(WebCore::FrameLoader::setDocumentLoader):
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):

  • loader/FrameLoaderTypes.h:
  • loader/PolicyChecker.cpp:

(WebCore::PolicyChecker::checkNavigationPolicy):

  • loader/PolicyChecker.h:

Source/WebKit:

To support PageCache when process-swap on cross-site navigation is enabled,
we've been navigating the previous process to 'about:blank' when swapping.
This would trigger PageCaching of the page in the old process. While
convenient, this design has led to a lot of bugs because we did not really
want a navigation to happen in the old process.

To address the issue, when a WebPage is asked to suspend (for process-swap),
we now attempt to add it to PageCache and save it on the current HistoryItem,
*without* triggering any navigation. Any pending navigation gets cancelled
and we just suspend in place.

Later on, when we want to go back to this HistoryItem, we simply leverage the
existing WebPage::goToBackForwardItem() code path. The only subtlety is that
we're actually asking the WebPage to load a HistoryItem that is the current
one in the History. I had to tweak a some logic / assertions to support this
as this is not something we usually do. However, it actually works with very
little changes and successfully restores the PageCache entry on the current
HistoryItem.

There is no expected overall behavior change and ProcessSwap API tests (which
cover PageCache) still pass. This is merely a simpler design because it avoids
navigating to about:blank.

  • UIProcess/SuspendedPageProxy.cpp:

(WebKit::SuspendedPageProxy::didSuspend):
(WebKit::SuspendedPageProxy::didReceiveMessage):

  • UIProcess/SuspendedPageProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didSuspendAfterProcessSwap):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):

  • WebProcess/WebPage/WebDocumentLoader.cpp:

(WebKit::WebDocumentLoader::setNavigationID):

  • WebProcess/WebPage/WebFrame.cpp:

(WebKit::WebFrame::didReceivePolicyDecision):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::suspendForProcessSwap):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::origin):

Location:
trunk/Source
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239181 r239182  
     12018-12-13  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] We should not need to navigate to 'about:blank' to suspend pages
     4        https://bugs.webkit.org/show_bug.cgi?id=192668
     5        <rdar://problem/46701466>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * history/PageCache.cpp:
     10        (WebCore::PageCache::addIfCacheable):
     11        * history/PageCache.h:
     12        * loader/DocumentLoader.cpp:
     13        (WebCore::DocumentLoader::redirectReceived):
     14        (WebCore::DocumentLoader::willSendRequest):
     15        (WebCore::DocumentLoader::startLoadingMainResource):
     16        * loader/DocumentLoader.h:
     17        * loader/FrameLoader.cpp:
     18        (WebCore::FrameLoader::init):
     19        (WebCore::FrameLoader::stopAllLoaders):
     20        (WebCore::FrameLoader::setDocumentLoader):
     21        (WebCore::FrameLoader::commitProvisionalLoad):
     22        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
     23        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
     24        * loader/FrameLoaderTypes.h:
     25        * loader/PolicyChecker.cpp:
     26        (WebCore::PolicyChecker::checkNavigationPolicy):
     27        * loader/PolicyChecker.h:
     28
    1292018-12-13  Per Arne Vollan  <pvollan@apple.com>
    230
  • trunk/Source/WebCore/history/PageCache.cpp

    r237446 r239182  
    426426}
    427427
    428 void PageCache::addIfCacheable(HistoryItem& item, Page* page)
     428bool PageCache::addIfCacheable(HistoryItem& item, Page* page)
    429429{
    430430    if (item.isInPageCache())
    431         return;
     431        return false;
    432432
    433433    if (!page || !canCache(*page))
    434         return;
     434        return false;
    435435
    436436    ASSERT_WITH_MESSAGE(!page->isUtilityPage(), "Utility pages such as SVGImage pages should never go into PageCache");
     
    450450    if (!canCache(*page)) {
    451451        setPageCacheState(*page, Document::NotInPageCache);
    452         return;
     452        return false;
    453453    }
    454454
     
    466466    }
    467467    prune(PruningReason::ReachedMaxSize);
     468    return true;
    468469}
    469470
  • trunk/Source/WebCore/history/PageCache.h

    r232098 r239182  
    5252    unsigned maxSize() const { return m_maxSize; }
    5353
    54     void addIfCacheable(HistoryItem&, Page*); // Prunes if maxSize() is exceeded.
     54    WEBCORE_EXPORT bool addIfCacheable(HistoryItem&, Page*); // Prunes if maxSize() is exceeded.
    5555    WEBCORE_EXPORT void remove(HistoryItem&);
    5656    CachedPage* get(HistoryItem&, Page*);
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r238771 r239182  
    516516#if ENABLE(SERVICE_WORKER)
    517517    bool isRedirectionFromServiceWorker = redirectResponse.source() == ResourceResponse::Source::ServiceWorker;
    518     willSendRequest(WTFMove(request), redirectResponse, ShouldContinue::Yes, [isRedirectionFromServiceWorker, completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this), this] (auto&& request) mutable {
     518    willSendRequest(WTFMove(request), redirectResponse, [isRedirectionFromServiceWorker, completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this), this] (auto&& request) mutable {
    519519        ASSERT(!m_substituteData.isValid());
    520520        if (request.isNull() || !m_mainDocumentError.isNull() || !m_frame) {
     
    549549    });
    550550#else
    551     willSendRequest(WTFMove(request), redirectResponse, ShouldContinue::Yes, WTFMove(completionHandler));
    552 #endif
    553 }
    554 
    555 void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const ResourceResponse& redirectResponse, ShouldContinue shouldContinue, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
     551    willSendRequest(WTFMove(request), redirectResponse, WTFMove(completionHandler));
     552#endif
     553}
     554
     555void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const ResourceResponse& redirectResponse, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
    556556{
    557557    // Note that there are no asserts here as there are for the other callbacks. This is due to the
     
    560560    // callbacks is meant to prevent.
    561561    ASSERT(!newRequest.isNull());
    562 
    563     ASSERT(shouldContinue != ShouldContinue::No);
    564562
    565563    bool didReceiveRedirectResponse = !redirectResponse.isNull();
     
    629627    setRequest(newRequest);
    630628
    631     if (!didReceiveRedirectResponse && shouldContinue != ShouldContinue::ForSuspension)
     629    if (!didReceiveRedirectResponse)
    632630        return completionHandler(WTFMove(newRequest));
    633631
     
    635633        m_waitingForNavigationPolicy = false;
    636634        switch (shouldContinue) {
    637         case ShouldContinue::ForSuspension:
    638             // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume.
    639             request = { WTF::blankURL() };
    640             break;
    641635        case ShouldContinue::No:
    642636            stopLoadingForPolicyChange();
     
    651645    ASSERT(!m_waitingForNavigationPolicy);
    652646    m_waitingForNavigationPolicy = true;
    653 
    654     if (shouldContinue == ShouldContinue::ForSuspension) {
    655         navigationPolicyCompletionHandler(WTFMove(newRequest), nullptr, shouldContinue);
    656         return;
    657     }
    658647
    659648    frameLoader()->policyChecker().checkNavigationPolicy(WTFMove(newRequest), redirectResponse, WTFMove(navigationPolicyCompletionHandler));
     
    16941683}
    16951684
    1696 void DocumentLoader::startLoadingMainResource(ShouldContinue shouldContinue)
    1697 {
    1698     ASSERT(shouldContinue != ShouldContinue::No);
    1699 
     1685void DocumentLoader::startLoadingMainResource()
     1686{
    17001687    m_mainDocumentError = ResourceError();
    17011688    timing().markStartTimeAndFetchStart();
     
    17231710    ASSERT(timing().fetchStart());
    17241711
    1725     willSendRequest(ResourceRequest(m_request), ResourceResponse(), shouldContinue, [this, protectedThis = WTFMove(protectedThis)] (ResourceRequest&& request) mutable {
     1712    willSendRequest(ResourceRequest(m_request), ResourceResponse(), [this, protectedThis = WTFMove(protectedThis)] (ResourceRequest&& request) mutable {
    17261713        m_request = request;
    17271714
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r239046 r239182  
    248248    void setMainResourceDataBufferingPolicy(DataBufferingPolicy);
    249249
    250     void startLoadingMainResource(ShouldContinue);
     250    void startLoadingMainResource();
    251251    WEBCORE_EXPORT void cancelMainResourceLoad(const ResourceError&);
    252252    void willContinueMainResourceLoadAfterRedirect(const ResourceRequest&);
     
    368368#endif
    369369
    370     void willSendRequest(ResourceRequest&&, const ResourceResponse&, ShouldContinue, CompletionHandler<void(ResourceRequest&&)>&&);
     370    void willSendRequest(ResourceRequest&&, const ResourceResponse&, CompletionHandler<void(ResourceRequest&&)>&&);
    371371    void finishedLoading();
    372372    void mainReceivedError(const ResourceError&);
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r239046 r239182  
    313313    setPolicyDocumentLoader(m_client.createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData()).ptr());
    314314    setProvisionalDocumentLoader(m_policyDocumentLoader.get());
    315     m_provisionalDocumentLoader->startLoadingMainResource(ShouldContinue::Yes);
     315    m_provisionalDocumentLoader->startLoadingMainResource();
    316316
    317317    Ref<Frame> protect(m_frame);
     
    17731773void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
    17741774{
    1775     ASSERT(!m_frame.document() || m_frame.document()->pageCacheState() != Document::InPageCache);
     1775    if (m_frame.document() && m_frame.document()->pageCacheState() == Document::InPageCache)
     1776        return;
     1777
    17761778    if (!isStopLoadingAllowed())
    17771779        return;
     
    18661868{
    18671869    if (!loader && !m_documentLoader)
     1870        return;
     1871
     1872    if (loader == m_documentLoader)
    18681873        return;
    18691874   
     
    19541959    willTransitionToCommitted();
    19551960
    1956     if (!m_frame.tree().parent() && history().currentItem()) {
     1961    if (!m_frame.tree().parent() && history().currentItem() && history().currentItem() != history().provisionalItem()) {
    19571962        // Check to see if we need to cache the page we are navigating away from into the back/forward cache.
    19581963        // We are doing this here because we know for sure that a new page is about to be loaded.
     
    33493354    }
    33503355
    3351     CompletionHandler<void()> completionHandler = [this, protectedFrame = makeRef(m_frame), shouldContinue] () mutable {
     3356    CompletionHandler<void()> completionHandler = [this, protectedFrame = makeRef(m_frame)] () mutable {
    33523357        if (!m_provisionalDocumentLoader)
    33533358            return;
    33543359       
    3355         prepareForLoadStart([this, protectedFrame = WTFMove(protectedFrame), shouldContinue] {
     3360        prepareForLoadStart([this, protectedFrame = WTFMove(protectedFrame)] {
    33563361
    33573362            // The load might be cancelled inside of prepareForLoadStart(), nulling out the m_provisionalDocumentLoader,
     
    33703375            m_loadingFromCachedPage = false;
    33713376
    3372             // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume.
    3373             if (shouldContinue == ShouldContinue::ForSuspension) {
    3374                 // Make sure we do a standard load to about:blank instead of reusing whatever the load type was on process swap.
    3375                 // For example, using a Back/Forward load to load about blank would cause the current HistoryItem's url to be
    3376                 // overwritten with 'about:blank', which we do not want.
    3377                 m_loadType = FrameLoadType::Standard;
    3378                 m_provisionalDocumentLoader->willContinueMainResourceLoadAfterRedirect({ WTF::blankURL() });
    3379             }
    3380 
    3381             m_provisionalDocumentLoader->startLoadingMainResource(shouldContinue);
     3377            m_provisionalDocumentLoader->startLoadingMainResource();
    33823378        });
    33833379    };
     
    33943390    FormState* formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy openerPolicy)
    33953391{
    3396     ASSERT(shouldContinue != ShouldContinue::ForSuspension);
    33973392    if (shouldContinue != ShouldContinue::Yes)
    33983393        return;
  • trunk/Source/WebCore/loader/FrameLoaderTypes.h

    r237264 r239182  
    4545    Download,
    4646    Ignore,
    47     Suspend,
     47    Suspend, // FIXME: This is only used by WebKit2 so we shouldn't need this in the WebCore enum.
    4848};
    4949
  • trunk/Source/WebCore/loader/PolicyChecker.cpp

    r238787 r239182  
    184184            return function({ }, nullptr, ShouldContinue::No);
    185185        case PolicyAction::Suspend:
    186             return function({ WTF::blankURL() }, nullptr, ShouldContinue::ForSuspension);
     186            RELEASE_ASSERT_NOT_REACHED();
    187187        case PolicyAction::Use:
    188188            if (!m_frame.loader().client().canHandleRequest(request)) {
  • trunk/Source/WebCore/loader/PolicyChecker.h

    r238633 r239182  
    5555enum class ShouldContinue {
    5656    Yes,
    57     No,
    58     ForSuspension
     57    No
    5958};
    6059
  • trunk/Source/WebKit/ChangeLog

    r239170 r239182  
     12018-12-13  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] We should not need to navigate to 'about:blank' to suspend pages
     4        https://bugs.webkit.org/show_bug.cgi?id=192668
     5        <rdar://problem/46701466>
     6
     7        Reviewed by Alex Christensen.
     8
     9        To support PageCache when process-swap on cross-site navigation is enabled,
     10        we've been navigating the previous process to 'about:blank' when swapping.
     11        This would trigger PageCaching of the page in the old process. While
     12        convenient, this design has led to a lot of bugs because we did not really
     13        want a navigation to happen in the old process.
     14
     15        To address the issue, when a WebPage is asked to suspend (for process-swap),
     16        we now attempt to add it to PageCache and save it on the current HistoryItem,
     17        *without* triggering any navigation. Any pending navigation gets cancelled
     18        and we just suspend in place.
     19
     20        Later on, when we want to go back to this HistoryItem, we simply leverage the
     21        existing WebPage::goToBackForwardItem() code path. The only subtlety is that
     22        we're actually asking the WebPage to load a HistoryItem that is the current
     23        one in the History. I had to tweak a some logic / assertions to support this
     24        as this is not something we usually do. However, it actually works with very
     25        little changes and successfully restores the PageCache entry on the current
     26        HistoryItem.
     27
     28        There is no expected overall behavior change and ProcessSwap API tests (which
     29        cover PageCache) still pass. This is merely a simpler design because it avoids
     30        navigating to about:blank.
     31
     32        * UIProcess/SuspendedPageProxy.cpp:
     33        (WebKit::SuspendedPageProxy::didSuspend):
     34        (WebKit::SuspendedPageProxy::didReceiveMessage):
     35        * UIProcess/SuspendedPageProxy.h:
     36        * UIProcess/WebPageProxy.cpp:
     37        (WebKit::WebPageProxy::didSuspendAfterProcessSwap):
     38        * UIProcess/WebPageProxy.h:
     39        * UIProcess/WebPageProxy.messages.in:
     40        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     41        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
     42        * WebProcess/WebPage/WebDocumentLoader.cpp:
     43        (WebKit::WebDocumentLoader::setNavigationID):
     44        * WebProcess/WebPage/WebFrame.cpp:
     45        (WebKit::WebFrame::didReceivePolicyDecision):
     46        * WebProcess/WebPage/WebPage.cpp:
     47        (WebKit::WebPage::suspendForProcessSwap):
     48        * WebProcess/WebPage/WebPage.h:
     49        * WebProcess/cocoa/WebProcessCocoa.mm:
     50        (WebKit::origin):
     51
    1522018-12-13  Per Arne Vollan  <pvollan@apple.com>
    253
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp

    r239080 r239182  
    131131}
    132132
    133 void SuspendedPageProxy::didFinishLoad()
     133void SuspendedPageProxy::didSuspend()
    134134{
    135135    LOG(ProcessSwapping, "SuspendedPageProxy %s from process %i finished transition to suspended", loggingString(), m_process->processIdentifier());
    136136
    137137    m_finishedSuspending = true;
    138 
    139     m_process->send(Messages::WebProcess::UpdateActivePages(), 0);
    140138
    141139#if PLATFORM(IOS_FAMILY)
     
    160158    ASSERT(decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName());
    161159
    162     if (decoder.messageName() == Messages::WebPageProxy::DidFinishLoadForFrame::name()) {
    163         didFinishLoad();
     160    if (decoder.messageName() == Messages::WebPageProxy::DidSuspendAfterProcessSwap::name()) {
     161        didSuspend();
    164162        return;
    165163    }
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h

    r239080 r239182  
    5656
    5757private:
    58     void didFinishLoad();
     58    void didSuspend();
    5959    void didFailToSuspend();
    6060
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r239144 r239182  
    751751        return false;
    752752
     753    if (isPageOpenedByDOMShowingInitialEmptyDocument())
     754        return false;
     755
    753756    auto* currentItem = navigation.fromItem();
    754757    if (!currentItem) {
     
    26272630
    26282631        if (processForNavigation.ptr() != &process()) {
    2629             policyAction = PolicyAction::Suspend;
     2632            policyAction = isPageOpenedByDOMShowingInitialEmptyDocument() ? PolicyAction::Ignore : PolicyAction::Suspend;
    26302633            RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, swapping process %i with process %i for navigation, reason: %{public}s", this, processIdentifier(), processForNavigation->processIdentifier(), reason.utf8().data());
    26312634            LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), processForNavigation->processIdentifier(), navigation->navigationID(), navigation->loggingString());
     
    27452748    };
    27462749
    2747     bool isInitialNavigationInNewWindow = openedByDOM() && !hasCommittedAnyProvisionalLoads();
    2748     if (!m_process->processPool().configuration().processSwapsOnWindowOpenWithOpener() || !isInitialNavigationInNewWindow || !mainFrameIDInPreviousProcess) {
     2750    if (!m_process->processPool().configuration().processSwapsOnWindowOpenWithOpener() || !isPageOpenedByDOMShowingInitialEmptyDocument() || !mainFrameIDInPreviousProcess) {
    27492751        // There is no way we'll be able to return to the page in the previous page so close it.
    27502752        if (!didSuspendPreviousPage)
     
    27602762}
    27612763
     2764bool WebPageProxy::isPageOpenedByDOMShowingInitialEmptyDocument() const
     2765{
     2766    return openedByDOM() && !hasCommittedAnyProvisionalLoads();
     2767}
     2768
    27622769// MSVC gives a redeclaration error if noreturn is used on the definition and not the declaration, while
    27632770// Cocoa tests segfault if it is moved to the declaration site (even if we move the definition with it!).
     
    27662773#endif
    27672774void WebPageProxy::didFailToSuspendAfterProcessSwap()
     2775{
     2776    // Only the SuspendedPageProxy should be getting this call.
     2777    ASSERT_NOT_REACHED();
     2778}
     2779
     2780#if !COMPILER(MSVC)
     2781NO_RETURN_DUE_TO_ASSERT
     2782#endif
     2783void WebPageProxy::didSuspendAfterProcessSwap()
    27682784{
    27692785    // Only the SuspendedPageProxy should be getting this call.
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r239133 r239182  
    13931393    void setDefersLoadingForTesting(bool);
    13941394
     1395    bool isPageOpenedByDOMShowingInitialEmptyDocument() const;
     1396
    13951397    WebCore::IntRect syncRootViewToScreen(const WebCore::IntRect& viewRect);
    13961398
     
    15681570    void swapToWebProcess(Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>&&, ShouldDelayAttachingDrawingArea);
    15691571    void didFailToSuspendAfterProcessSwap();
     1572    void didSuspendAfterProcessSwap();
    15701573
    15711574    void finishAttachingToWebProcess(ShouldDelayAttachingDrawingArea = ShouldDelayAttachingDrawingArea::No);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r239080 r239182  
    506506
    507507    DidFailToSuspendAfterProcessSwap()
     508    DidSuspendAfterProcessSwap()
    508509
    509510    ImageOrMediaDocumentSizeChanged(WebCore::IntSize newSize)
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r239080 r239182  
    21982198        return completionHandler(page.process(), nullptr, "The treatAsSameOriginNavigation flag is set"_s);
    21992199
    2200     bool isInitialLoadInNewWindowOpenedByDOM = page.openedByDOM() && !page.hasCommittedAnyProvisionalLoads();
    22012200    URL sourceURL;
    2202     if (isInitialLoadInNewWindowOpenedByDOM && !navigation.requesterOrigin().isEmpty())
     2201    if (page.isPageOpenedByDOMShowingInitialEmptyDocument() && !navigation.requesterOrigin().isEmpty())
    22032202        sourceURL = URL { URL(), navigation.requesterOrigin().toString() };
    22042203    else
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r238819 r239182  
    736736    }
    737737
    738     // For suspension loads to about:blank, no need to ask the SuspendedPageProxy.
    739     if (request.url() == WTF::blankURL() && webPage->isSuspended()) {
    740         function(PolicyAction::Use);
    741         return;
    742     }
    743 
    744738    RefPtr<API::Object> userData;
    745739
  • trunk/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp

    r235205 r239182  
    5151{
    5252    ASSERT(navigationID);
    53     ASSERT(!m_navigationID || m_navigationID == navigationID);
    5453
    5554    m_navigationID = navigationID;
  • trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp

    r239080 r239182  
    276276    }
    277277
     278    bool shouldSuspend = false;
     279    if (action == PolicyAction::Suspend) {
     280        shouldSuspend = true;
     281        action = PolicyAction::Ignore;
     282    }
     283
    278284    function(action);
     285
     286    if (shouldSuspend)
     287        page()->suspendForProcessSwap();
    279288}
    280289
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r239167 r239182  
    185185#include <WebCore/NotImplemented.h>
    186186#include <WebCore/Page.h>
     187#include <WebCore/PageCache.h>
    187188#include <WebCore/PageConfiguration.h>
    188189#include <WebCore/PingLoader.h>
     
    13121313}
    13131314
     1315void WebPage::suspendForProcessSwap()
     1316{
     1317    auto failedToSuspend = [this, protectedThis = makeRef(*this)] {
     1318        close();
     1319        send(Messages::WebPageProxy::DidFailToSuspendAfterProcessSwap());
     1320    };
     1321
     1322    auto* currentHistoryItem = m_mainFrame->coreFrame()->loader().history().currentItem();
     1323    if (!currentHistoryItem) {
     1324        failedToSuspend();
     1325        return;
     1326    }
     1327
     1328    if (!PageCache::singleton().addIfCacheable(*currentHistoryItem, corePage())) {
     1329        failedToSuspend();
     1330        return;
     1331    }
     1332
     1333    send(Messages::WebPageProxy::DidSuspendAfterProcessSwap());
     1334}
     1335
    13141336void WebPage::loadURLInFrame(URL&& url, uint64_t frameID)
    13151337{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r239167 r239182  
    451451    void sendClose();
    452452
     453    void suspendForProcessSwap();
     454
    453455    void sendSetWindowFrame(const WebCore::FloatRect&);
    454456
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r238771 r239182  
    461461
    462462    URL mainFrameURL = { URL(), mainFrame->url() };
    463     if (page.isSuspended()) {
    464         // Suspended page are navigated to about:blank upon suspension so we really want to report the previous URL.
    465         if (auto* coreFrame = mainFrame->coreFrame()) {
    466             if (auto* backHistoryItem = coreFrame->loader().history().previousItem())
    467                 mainFrameURL = { URL(), backHistoryItem->urlString() };
    468         }
    469     }
    470 
    471463    Ref<SecurityOrigin> mainFrameOrigin = SecurityOrigin::create(mainFrameURL);
    472464    String mainFrameOriginString;
Note: See TracChangeset for help on using the changeset viewer.