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

Changeset 236257 in webkit


Ignore:
Timestamp:
Sep 20, 2018, 4:49:55 AM (8 years ago)
Author:
Antti Koivisto
Message:

REGRESSION (PSON): White or Black flash occurs when process swapping on navigation on Mac
​https://bugs.webkit.org/show_bug.cgi?id=189663
<rdar://problem/44184955>

Reviewed by Geoff Garen and Chris Dumez.

We need to keep the layer tree of the previous page alive and visible until we have something
to render on the new page. With PSON on Mac this means that we should keep displaying the
layer tree from the previus process.

This patch moves the management of 'attaching' the drawing area (Mac only concept) from web process
to UI process. This is when we parent the layer tree to the view root layer. It also ensures that
the layer tree is not deleted too early on process swap and that it still eventually gets deleted.

  • UIProcess/DrawingAreaProxy.h:

(WebKit::DrawingAreaProxy::attachInWebProcess):

  • UIProcess/SuspendedPageProxy.cpp:

(WebKit::messageNamesToIgnoreWhileSuspended):
(WebKit::SuspendedPageProxy::tearDownDrawingAreaInWebProcess):

We no longer tear down drawing area (layer tree) for suspended pages automatically. Send an explicit
message for it.

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

(WebKit::WebPageProxy::didCompletePageTransition):

Attach the drawing area if appropriate.

(WebKit::WebPageProxy::resetStateAfterProcessExited):

Call PageClien::processWillSwap instead of processDidExit when appropriate.

(WebKit::WebPageProxy::enterAcceleratedCompositingMode):

This is called when we have switched to the new layer tree.
Tear down the drawing area in the previus process.

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::processWillSwap):

On iOS this just call processDidExit for now.

  • UIProcess/mac/PageClientImplMac.h:
  • UIProcess/mac/PageClientImplMac.mm:

(WebKit::PageClientImpl::processWillSwap):
(WebKit::PageClientImpl::processDidExit):

Add processWillSwap separately from processDidExit. They are currently the same
except processWillSwap doesn't clear the root layer.

  • UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
  • UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:

(WebKit::TiledCoreAnimationDrawingAreaProxy::attachInWebProcess):

Send a message to the web process to attach the drawing area.

  • WebProcess/WebPage/DrawingArea.h:

(WebKit::DrawingArea::attach):
(WebKit::DrawingArea::attachDrawingArea): Deleted.

Rename to be less redundant.

  • WebProcess/WebPage/DrawingArea.messages.in:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::reinitializeWebPage):

Don't attach drawing area automatically. It will be done by a message from UI process.

(WebKit::WebPage::setLayerTreeStateIsFrozen):

Layer tree is always frozen in a suspended process (if it exists).

(WebKit::WebPage::didReceivePolicyDecision):

Suspend immediately when receiving policy decision to avoid flash on 'about:blank' loading.

(WebKit::WebPage::didStartPageTransition):
(WebKit::WebPage::didCompletePageTransition):

Notify UI process of transition completion.

(WebKit::WebPage::setIsSuspended):
(WebKit::WebPage::tearDownDrawingAreaForSuspend):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
  • WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:

(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):

Don't attach drawing area automatically. It will be done by a message from UI process.

(WebKit::TiledCoreAnimationDrawingArea::attach):
(WebKit::TiledCoreAnimationDrawingArea::attachDrawingArea): Deleted.

Location:
trunk/Source/WebKit
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r236245 r236257  
     12018-09-20  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (PSON): White or Black flash occurs when process swapping on navigation on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=189663
     5        <rdar://problem/44184955>
     6
     7        Reviewed by Geoff Garen and Chris Dumez.
     8
     9        We need to keep the layer tree of the previous page alive and visible until we have something
     10        to render on the new page. With PSON on Mac this means that we should keep displaying the
     11        layer tree from the previus process.
     12
     13        This patch moves the management of 'attaching' the drawing area (Mac only concept) from web process
     14        to UI process. This is when we parent the layer tree to the view root layer. It also ensures that
     15        the layer tree is not deleted too early on process swap and that it still eventually gets deleted.
     16
     17        * UIProcess/DrawingAreaProxy.h:
     18        (WebKit::DrawingAreaProxy::attachInWebProcess):
     19        * UIProcess/SuspendedPageProxy.cpp:
     20        (WebKit::messageNamesToIgnoreWhileSuspended):
     21        (WebKit::SuspendedPageProxy::tearDownDrawingAreaInWebProcess):
     22
     23        We no longer tear down drawing area (layer tree) for suspended pages automatically. Send an explicit
     24        message for it.
     25
     26        * UIProcess/SuspendedPageProxy.h:
     27        * UIProcess/WebPageProxy.cpp:
     28        (WebKit::WebPageProxy::didCompletePageTransition):
     29
     30        Attach the drawing area if appropriate.
     31
     32        (WebKit::WebPageProxy::resetStateAfterProcessExited):
     33
     34        Call PageClien::processWillSwap instead of processDidExit when appropriate.
     35
     36        (WebKit::WebPageProxy::enterAcceleratedCompositingMode):
     37
     38        This is called when we have switched to the new layer tree.
     39        Tear down the drawing area in the previus process.
     40
     41        * UIProcess/WebPageProxy.h:
     42        * UIProcess/WebPageProxy.messages.in:
     43        * UIProcess/ios/PageClientImplIOS.h:
     44        * UIProcess/ios/PageClientImplIOS.mm:
     45        (WebKit::PageClientImpl::processWillSwap):
     46
     47        On iOS this just call processDidExit for now.
     48
     49        * UIProcess/mac/PageClientImplMac.h:
     50        * UIProcess/mac/PageClientImplMac.mm:
     51        (WebKit::PageClientImpl::processWillSwap):
     52        (WebKit::PageClientImpl::processDidExit):
     53
     54        Add processWillSwap separately from processDidExit. They are currently the same
     55        except processWillSwap doesn't clear the root layer.
     56
     57        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
     58        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
     59        (WebKit::TiledCoreAnimationDrawingAreaProxy::attachInWebProcess):
     60
     61        Send a message to the web process to attach the drawing area.
     62
     63        * WebProcess/WebPage/DrawingArea.h:
     64        (WebKit::DrawingArea::attach):
     65        (WebKit::DrawingArea::attachDrawingArea): Deleted.
     66
     67        Rename to be less redundant.
     68
     69        * WebProcess/WebPage/DrawingArea.messages.in:
     70        * WebProcess/WebPage/WebPage.cpp:
     71        (WebKit::WebPage::reinitializeWebPage):
     72
     73        Don't attach drawing area automatically. It will be done by a message from UI process.
     74
     75        (WebKit::WebPage::setLayerTreeStateIsFrozen):
     76
     77        Layer tree is always frozen in a suspended process (if it exists).
     78
     79        (WebKit::WebPage::didReceivePolicyDecision):
     80
     81        Suspend immediately when receiving policy decision to avoid flash on 'about:blank' loading.
     82
     83        (WebKit::WebPage::didStartPageTransition):
     84        (WebKit::WebPage::didCompletePageTransition):
     85
     86        Notify UI process of transition completion.
     87
     88        (WebKit::WebPage::setIsSuspended):
     89        (WebKit::WebPage::tearDownDrawingAreaForSuspend):
     90        * WebProcess/WebPage/WebPage.h:
     91        * WebProcess/WebPage/WebPage.messages.in:
     92        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
     93        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
     94        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
     95
     96        Don't attach drawing area automatically. It will be done by a message from UI process.
     97
     98        (WebKit::TiledCoreAnimationDrawingArea::attach):
     99        (WebKit::TiledCoreAnimationDrawingArea::attachDrawingArea): Deleted.
     100
    11012018-09-20  Tomas Popela  <tpopela@redhat.com>
    2102
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r235955 r236257  
    14611461    notifyInputContextAboutDiscardedComposition();
    14621462
    1463     if (m_layerHostingView)
    1464         setAcceleratedCompositingRootLayer(nil);
    1465 
    14661463    updateRemoteAccessibilityRegistration(false);
    14671464    flushPendingMouseEventCallbacks();
  • trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h

    r236146 r236257  
    8383#endif
    8484
     85    virtual void attachInWebProcess() { }
     86
    8587    virtual void updateDebugIndicator() { }
    8688
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r235907 r236257  
    185185
    186186    virtual void processDidExit() = 0;
     187    virtual void processWillSwap() { processDidExit(); }
    187188    virtual void didRelaunchProcess() = 0;
    188189    virtual void pageClosed() = 0;
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp

    r236226 r236257  
    5555        messageNames.get().add("DidFinishDocumentLoadForFrame");
    5656        messageNames.get().add("DidFinishProgress");
     57        messageNames.get().add("DidCompletePageTransition");
    5758        messageNames.get().add("DidFirstLayoutForFrame");
    5859        messageNames.get().add("DidFirstVisuallyNonEmptyLayoutForFrame");
    … …  
    110111}
    111112
     113void SuspendedPageProxy::tearDownDrawingAreaInWebProcess()
     114{
     115    m_process->send(Messages::WebPage::TearDownDrawingAreaForSuspend(), m_page.pageID());
     116}
     117
    112118void SuspendedPageProxy::didFinishLoad()
    113119{
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h

    r236226 r236257  
    5050    void webProcessDidClose(WebProcessProxy&);
    5151    void destroyWebPageInWebProcess();
     52    void tearDownDrawingAreaInWebProcess();
    5253
    5354#if !LOG_DISABLED
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r236227 r236257  
    5757#include "DataReference.h"
    5858#include "DownloadProxy.h"
     59#include "DrawingAreaMessages.h"
    5960#include "DrawingAreaProxy.h"
    60 #include "DrawingAreaProxyMessages.h"
    6161#include "EventDispatcherMessages.h"
    6262#include "FrameInfoData.h"
    … …  
    34313431}
    34323432
     3433void WebPageProxy::didCompletePageTransition(bool isInitialEmptyDocument)
     3434{
     3435    // Attach drawing area for the initial empty document only if this is not a process swap.
     3436    if (isInitialEmptyDocument && m_suspendedPage)
     3437        return;
     3438
     3439#if PLATFORM(MAC)
     3440    if (!m_drawingArea)
     3441        return;
     3442
     3443    // Drawing area for the suspended page will be torn down when the attach completes.
     3444    m_drawingArea->attachInWebProcess();
     3445#else
     3446    if (m_suspendedPage)
     3447        m_suspendedPage->tearDownDrawingAreaInWebProcess();
     3448#endif
     3449}
     3450
    34333451void WebPageProxy::setNetworkRequestsInProgress(bool networkRequestsInProgress)
    34343452{
    … …  
    61386156    m_editorState = EditorState();
    61396157
    6140     pageClient().processDidExit();
     6158    if (terminationReason == ProcessTerminationReason::NavigationSwap)
     6159        pageClient().processWillSwap();
     6160    else
     6161        pageClient().processDidExit();
     6162
    61416163    pageClient().clearAllEditCommands();
    61426164
    … …  
    62796301{
    62806302    pageClient().enterAcceleratedCompositingMode(layerTreeContext);
     6303
     6304    // We have completed the page transition and can tear down the layers in the suspended process.
     6305    if (m_suspendedPage)
     6306        m_suspendedPage->tearDownDrawingAreaInWebProcess();
    62816307}
    62826308
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r236154 r236257  
    14281428    void didChangeProgress(double);
    14291429    void didFinishProgress();
     1430    void didCompletePageTransition(bool isInitialEmptyDocument);
    14301431    void setNetworkRequestsInProgress(bool);
    14311432
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r236146 r236257  
    118118    DidStartProgress()
    119119
     120    DidCompletePageTransition(bool isInitialEmptyDocument)
     121
    120122    SetNetworkRequestsInProgress(bool networkRequestsInProgress)
    121123
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r235741 r236257  
    6666    bool isVisuallyIdle() override;
    6767    void processDidExit() override;
     68    void processWillSwap() override;
    6869    void didRelaunchProcess() override;
    6970    void pageClosed() override;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r235878 r236257  
    210210}
    211211
     212void PageClientImpl::processWillSwap()
     213{
     214    // FIXME: It didn't really exit.
     215    processDidExit();
     216}
     217
    212218void PageClientImpl::didRelaunchProcess()
    213219{
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r235925 r236257  
    8080
    8181    void processDidExit() override;
     82    void processWillSwap() override;
    8283    void pageClosed() override;
    8384    void didRelaunchProcess() override;
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r235935 r236257  
    254254}
    255255
     256void PageClientImpl::processWillSwap()
     257{
     258    // FIXME: It didn't really exit.
     259    m_impl->processDidExit();
     260}
     261
    256262void PageClientImpl::processDidExit()
    257263{
    258264    m_impl->processDidExit();
     265    m_impl->setAcceleratedCompositingRootLayer(nil);
    259266}
    260267
  • trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h

    r236146 r236257  
    3939private:
    4040    // DrawingAreaProxy
     41    void attachInWebProcess() override;
     42
    4143    void deviceScaleFactorDidChange() override;
    4244    void sizeDidChange() override;
  • trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm

    r236146 r236257  
    5454}
    5555
     56void TiledCoreAnimationDrawingAreaProxy::attachInWebProcess()
     57{
     58    m_webPageProxy.process().send(Messages::DrawingArea::Attach(), m_webPageProxy.pageID());
     59}
     60
    5661void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
    5762{
  • trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h

    r236146 r236257  
    152152#endif
    153153
    154     virtual void attachDrawingArea() { };
     154    virtual void attach() { };
    155155
    156156protected:
  • trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in

    r236146 r236257  
    4646#endif
    4747
    48 #if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     48#if PLATFORM(MAC)
     49    Attach()
     50
     51#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    4952    DisplayWasRefreshed()
    5053#endif
     54#endif
    5155}
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r236146 r236257  
    658658        m_drawingArea->setPaintingEnabled(true);
    659659    }
    660     m_drawingArea->attachDrawingArea();
    661660
    662661    if (m_activityState != parameters.activityState)
    … …  
    22162215        return;
    22172216
    2218     drawingArea->setLayerTreeStateIsFrozen(frozen);
     2217    drawingArea->setLayerTreeStateIsFrozen(frozen || m_isSuspended);
    22192218}
    22202219
    … …  
    28342833    if (!frame)
    28352834        return;
     2835    if (policyAction == PolicyAction::Suspend) {
     2836        ASSERT(frame == m_mainFrame);
     2837        setIsSuspended(true);
     2838    }
    28362839    frame->didReceivePolicyDecision(listenerID, policyAction, navigationID, downloadID, WTFMove(websitePolicies));
    28372840}
    … …  
    28472850void WebPage::didStartPageTransition()
    28482851{
    2849     m_drawingArea->setLayerTreeStateIsFrozen(true);
     2852    setLayerTreeStateIsFrozen(true);
    28502853
    28512854#if PLATFORM(MAC)
    … …  
    28712874void WebPage::didCompletePageTransition()
    28722875{
    2873     if (m_drawingArea)
    2874         m_drawingArea->setLayerTreeStateIsFrozen(false);
     2876    // FIXME: Layer tree freezing should be managed entirely in the UI process side.
     2877    setLayerTreeStateIsFrozen(false);
     2878
     2879    bool isInitialEmptyDocument = !m_mainFrame;
     2880    send(Messages::WebPageProxy::DidCompletePageTransition(isInitialEmptyDocument));
    28752881}
    28762882
    … …  
    60016007
    60026008    m_isSuspended = suspended;
    6003     if (m_isSuspended)
    6004         m_drawingArea = nullptr;
     6009
     6010    setLayerTreeStateIsFrozen(true);
     6011}
     6012
     6013void WebPage::tearDownDrawingAreaForSuspend()
     6014{
     6015    if (!m_isSuspended)
     6016        return;
     6017    m_drawingArea = nullptr;
    60056018}
    60066019
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r236146 r236257  
    14151415
    14161416    void setIsSuspended(bool);
     1417    void tearDownDrawingAreaForSuspend();
    14171418
    14181419    RefPtr<WebImage> snapshotAtSize(const WebCore::IntRect&, const WebCore::IntSize& bitmapSize, SnapshotOptions);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r236146 r236257  
    507507
    508508    SetIsSuspended(bool suspended)
     509    TearDownDrawingAreaForSuspend();
    509510
    510511#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
  • trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h

    r236146 r236257  
    104104    void setShouldScaleViewToFitDocument(bool) override;
    105105
    106     void attachDrawingArea() override;
     106    void attach() override;
    107107
    108108    void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
  • trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

    r236146 r236257  
    9292    updateLayerHostingContext();
    9393    setColorSpace(parameters.colorSpace);
    94 
    95     attachDrawingArea();
    9694}
    9795
    … …  
    102100
    103101
    104 void TiledCoreAnimationDrawingArea::attachDrawingArea()
     102void TiledCoreAnimationDrawingArea::attach()
    105103{
    106104    LayerTreeContext layerTreeContext;
Note: See TracChangeset for help on using the changeset viewer.