Changeset 240443 in webkit


Ignore:
Timestamp:
Jan 24, 2019 10:35:05 AM (5 years ago)
Author:
Antti Koivisto
Message:

[PSON] Flash on back navigation on Mac
https://bugs.webkit.org/show_bug.cgi?id=193716
<rdar://problem/47148458>

Reviewed by Chris Dumez.

Source/WebKit:

We close the page immediately if we fail to suspend. Layers disappear and we get a flash.

  • UIProcess/SuspendedPageProxy.cpp:

(WebKit::SuspendedPageProxy::~SuspendedPageProxy):
(WebKit::SuspendedPageProxy::close):

Track closed state so we don't send the message twice, causing unhandled message errors in web process.

(WebKit::SuspendedPageProxy::didProcessRequestToSuspend):

Close the suspended page if the suspension fails.
Skip this if we are using web process side compositing on Mac.

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

(WebKit::WebPageProxy::enterAcceleratedCompositingMode):

On Mac, close the failed SuspendedPageProxy when entering compositing mode. At this point we don't need it to keep layers alive.

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::closeFailedSuspendedPagesForPage):

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

(WebKit::WebPage::suspendForProcessSwap):

Don't close the page on suspension failure. This is now managed by the UI process.

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

Closing of the previous page is delayed so waiting for didFinishNavigation is
not sufficient to guarantee we have received all the messages. Wait for them.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r240442 r240443  
     12019-01-24  Antti Koivisto  <antti@apple.com>
     2
     3        [PSON] Flash on back navigation on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=193716
     5        <rdar://problem/47148458>
     6
     7        Reviewed by Chris Dumez.
     8
     9        We close the page immediately if we fail to suspend. Layers disappear and we get a flash.
     10
     11        * UIProcess/SuspendedPageProxy.cpp:
     12        (WebKit::SuspendedPageProxy::~SuspendedPageProxy):
     13        (WebKit::SuspendedPageProxy::close):
     14
     15        Track closed state so we don't send the message twice, causing unhandled message errors in web process.
     16
     17        (WebKit::SuspendedPageProxy::didProcessRequestToSuspend):
     18
     19        Close the suspended page if the suspension fails.
     20        Skip this if we are using web process side compositing on Mac.
     21
     22        * UIProcess/SuspendedPageProxy.h:
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::WebPageProxy::enterAcceleratedCompositingMode):
     25
     26        On Mac, close the failed SuspendedPageProxy when entering compositing mode. At this point we don't need it to keep layers alive.
     27
     28        * UIProcess/WebProcessPool.cpp:
     29        (WebKit::WebProcessPool::closeFailedSuspendedPagesForPage):
     30        * UIProcess/WebProcessPool.h:
     31        * WebProcess/WebPage/WebPage.cpp:
     32        (WebKit::WebPage::suspendForProcessSwap):
     33
     34        Don't close the page on suspension failure. This is now managed by the UI process.
     35
    1362019-01-24  Chris Dumez  <cdumez@apple.com>
    237
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp

    r240365 r240443  
    2727#include "SuspendedPageProxy.h"
    2828
     29#include "DrawingAreaProxy.h"
    2930#include "Logging.h"
    3031#include "WebPageMessages.h"
     
    100101    // If the suspended page was not consumed before getting destroyed, then close the corresponding page
    101102    // on the WebProcess side.
    102     m_process->send(Messages::WebPage::Close(), m_page.pageID());
     103    close();
    103104
    104105    if (m_suspensionState == SuspensionState::Suspending)
     
    140141}
    141142
     143void SuspendedPageProxy::close()
     144{
     145    ASSERT(m_suspensionState != SuspensionState::Resumed);
     146
     147    if (m_isClosed)
     148        return;
     149
     150    m_isClosed = true;
     151    m_process->send(Messages::WebPage::Close(), m_page.pageID());
     152}
     153
    142154void SuspendedPageProxy::didProcessRequestToSuspend(SuspensionState newSuspensionState)
    143155{
     
    154166
    155167    m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID());
     168
     169    bool shouldDelayClosingOnFailure = false;
     170#if PLATFORM(MAC)
     171    // With web process side tiles, we need to keep the suspended page around on failure to avoid flashing.
     172    // It is removed by WebPageProxy::enterAcceleratedCompositingMode when the target page is ready.
     173    shouldDelayClosingOnFailure = m_page.drawingArea() && m_page.drawingArea()->type() == DrawingAreaTypeTiledCoreAnimation;
     174#endif
     175    if (m_suspensionState == SuspensionState::FailedToSuspend && !shouldDelayClosingOnFailure)
     176        close();
    156177
    157178    if (m_readyToUnsuspendHandler)
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h

    r239997 r240443  
    5353    void waitUntilReadyToUnsuspend(CompletionHandler<void(SuspendedPageProxy*)>&&);
    5454    void unsuspend();
     55    void close();
    5556
    5657#if !LOG_DISABLED
     
    7071    uint64_t m_mainFrameID;
    7172    String m_registrableDomain;
     73    bool m_isClosed { false };
    7274
    7375    SuspensionState m_suspensionState { SuspensionState::Suspending };
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r240365 r240443  
    68486848void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
    68496849{
     6850#if PLATFORM(MAC)
     6851    ASSERT(m_drawingArea->type() == DrawingAreaTypeTiledCoreAnimation);
     6852#endif
    68506853    pageClient().enterAcceleratedCompositingMode(layerTreeContext);
     6854    // We needed the failed suspended page to stay alive to avoid flashing. Now we can get rid of it.
     6855    m_process->processPool().closeFailedSuspendedPagesForPage(*this);
    68516856}
    68526857
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r240365 r240443  
    22632263}
    22642264
     2265void WebProcessPool::closeFailedSuspendedPagesForPage(WebPageProxy& page)
     2266{
     2267    for (auto& suspendedPage : m_suspendedPages) {
     2268        if (&suspendedPage->page() == &page && suspendedPage->failedToSuspend())
     2269            suspendedPage->close();
     2270    }
     2271}
     2272
    22652273std::unique_ptr<SuspendedPageProxy> WebProcessPool::takeSuspendedPage(SuspendedPageProxy& suspendedPage)
    22662274{
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r240365 r240443  
    448448    void addSuspendedPage(std::unique_ptr<SuspendedPageProxy>&&);
    449449    void removeAllSuspendedPagesForPage(WebPageProxy&);
     450    void closeFailedSuspendedPagesForPage(WebPageProxy&);
    450451    std::unique_ptr<SuspendedPageProxy> takeSuspendedPage(SuspendedPageProxy&);
    451452    void removeSuspendedPage(SuspendedPageProxy&);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r240365 r240443  
    13411341{
    13421342    auto failedToSuspend = [this, protectedThis = makeRef(*this)] {
    1343         close();
    13441343        send(Messages::WebPageProxy::DidFailToSuspendAfterProcessSwap());
    13451344    };
  • trunk/Tools/ChangeLog

    r240442 r240443  
     12019-01-24  Antti Koivisto  <antti@apple.com>
     2
     3        [PSON] Flash on back navigation on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=193716
     5        <rdar://problem/47148458>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     10
     11        Closing of the previous page is delayed so waiting for didFinishNavigation is
     12        not sufficient to guarantee we have received all the messages. Wait for them.
     13
    1142019-01-24  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r240442 r240443  
    24142414    done = false;
    24152415
     2416    while ([receivedMessages count] < 7)
     2417        TestWebKitAPI::Util::sleep(0.1);
     2418
    24162419    EXPECT_EQ(7u, [receivedMessages count]);
    24172420    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html - pageshow NOT persisted", receivedMessages.get()[0]);
     
    25042507    done = false;
    25052508
     2509    while ([receivedMessages count] < 7)
     2510        TestWebKitAPI::Util::sleep(0.1);
     2511
    25062512    EXPECT_EQ(7u, [receivedMessages count]);
    25072513    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html - load", receivedMessages.get()[0]);
Note: See TracChangeset for help on using the changeset viewer.