DrawingArea should only capture painting related milestones
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:34:10 +0000 (21:34 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:34:10 +0000 (21:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196926
<rdar://problem/48003845>

Reviewed by Tim Horton.

While dispatching layout milestones (mixture of layout and painting items), the associated drawing areas should only capture the painting related milestones.
These captured milestones get dispatched later in the commit handler to ensure that they are not forwarded prematurely.
However the truly layout related milestones (e.g. DidFirstVisuallyNonEmptyLayout) should be dispatched right away with no delay.

* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::newlyReachedPaintingMilestones const):
(WebKit::RemoteLayerTreeTransaction::setNewlyReachedPaintingMilestones):
(WebKit::RemoteLayerTreeTransaction::newlyReachedLayoutMilestones const): Deleted.
(WebKit::RemoteLayerTreeTransaction::setNewlyReachedLayoutMilestones): Deleted.
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode const):
(WebKit::RemoteLayerTreeTransaction::decode):
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::addMilestonesToDispatch):
(WebKit::DrawingArea::dispatchDidReachLayoutMilestone): Deleted.
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
(WebKit::RemoteLayerTreeDrawingArea::addMilestonesToDispatch):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
(WebKit::RemoteLayerTreeDrawingArea::dispatchDidReachLayoutMilestone): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dispatchDidReachLayoutMilestone):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
(WebKit::TiledCoreAnimationDrawingArea::addMilestonesToDispatch):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::sendPendingNewlyReachedPaintingMilestones):
(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
(WebKit::TiledCoreAnimationDrawingArea::sendPendingNewlyReachedLayoutMilestones): Deleted.
(WebKit::TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244291 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit/WebProcess/WebPage/DrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index aaefc0a..90d91bf 100644 (file)
@@ -1,3 +1,43 @@
+2019-04-15  Zalan Bujtas  <zalan@apple.com>
+
+        DrawingArea should only capture painting related milestones
+        https://bugs.webkit.org/show_bug.cgi?id=196926
+        <rdar://problem/48003845>
+
+        Reviewed by Tim Horton.
+
+        While dispatching layout milestones (mixture of layout and painting items), the associated drawing areas should only capture the painting related milestones.
+        These captured milestones get dispatched later in the commit handler to ensure that they are not forwarded prematurely.
+        However the truly layout related milestones (e.g. DidFirstVisuallyNonEmptyLayout) should be dispatched right away with no delay.
+
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::newlyReachedPaintingMilestones const):
+        (WebKit::RemoteLayerTreeTransaction::setNewlyReachedPaintingMilestones):
+        (WebKit::RemoteLayerTreeTransaction::newlyReachedLayoutMilestones const): Deleted.
+        (WebKit::RemoteLayerTreeTransaction::setNewlyReachedLayoutMilestones): Deleted.
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode const):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::addMilestonesToDispatch):
+        (WebKit::DrawingArea::dispatchDidReachLayoutMilestone): Deleted.
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        (WebKit::RemoteLayerTreeDrawingArea::addMilestonesToDispatch):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        (WebKit::RemoteLayerTreeDrawingArea::dispatchDidReachLayoutMilestone): Deleted.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::dispatchDidReachLayoutMilestone):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        (WebKit::TiledCoreAnimationDrawingArea::addMilestonesToDispatch):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::sendPendingNewlyReachedPaintingMilestones):
+        (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
+        (WebKit::TiledCoreAnimationDrawingArea::sendPendingNewlyReachedLayoutMilestones): Deleted.
+        (WebKit::TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone): Deleted.
+
 2019-04-15  John Wilander  <wilander@apple.com>
 
         Send delayed Ad Click Attribution conversion requests to the click source
index 5917aaa..ea2be93 100644 (file)
@@ -271,8 +271,8 @@ public:
     const Vector<TransactionCallbackID>& callbackIDs() const { return m_callbackIDs; }
     void setCallbackIDs(Vector<TransactionCallbackID>&& callbackIDs) { m_callbackIDs = WTFMove(callbackIDs); }
 
-    OptionSet<WebCore::LayoutMilestone> newlyReachedLayoutMilestones() const { return m_newlyReachedLayoutMilestones; }
-    void setNewlyReachedLayoutMilestones(OptionSet<WebCore::LayoutMilestone> milestones) { m_newlyReachedLayoutMilestones = milestones; }
+    OptionSet<WebCore::LayoutMilestone> newlyReachedPaintingMilestones() const { return m_newlyReachedPaintingMilestones; }
+    void setNewlyReachedPaintingMilestones(OptionSet<WebCore::LayoutMilestone> milestones) { m_newlyReachedPaintingMilestones = milestones; }
 
     bool hasEditorState() const { return !!m_editorState; }
     const EditorState& editorState() const { return m_editorState.value(); }
@@ -308,7 +308,7 @@ private:
     uint64_t m_renderTreeSize { 0 };
     uint64_t m_transactionID { 0 };
     ActivityStateChangeID m_activityStateChangeID { ActivityStateChangeAsynchronous };
-    OptionSet<WebCore::LayoutMilestone> m_newlyReachedLayoutMilestones;
+    OptionSet<WebCore::LayoutMilestone> m_newlyReachedPaintingMilestones;
     bool m_scaleWasSetByUIProcess { false };
     bool m_allowsUserScaling { false };
     bool m_avoidsUnsafeArea { true };
index 4a03a28..1f2de4d 100644 (file)
@@ -562,7 +562,7 @@ void RemoteLayerTreeTransaction::encode(IPC::Encoder& encoder) const
     encoder << m_transactionID;
     encoder << m_activityStateChangeID;
 
-    encoder << m_newlyReachedLayoutMilestones;
+    encoder << m_newlyReachedPaintingMilestones;
 
     encoder << m_scaleWasSetByUIProcess;
     encoder << m_allowsUserScaling;
@@ -673,7 +673,7 @@ bool RemoteLayerTreeTransaction::decode(IPC::Decoder& decoder, RemoteLayerTreeTr
     if (!decoder.decode(result.m_activityStateChangeID))
         return false;
 
-    if (!decoder.decode(result.m_newlyReachedLayoutMilestones))
+    if (!decoder.decode(result.m_newlyReachedPaintingMilestones))
         return false;
 
     if (!decoder.decode(result.m_scaleWasSetByUIProcess))
index 7068443..e4de890 100644 (file)
@@ -255,7 +255,7 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
     didRefreshDisplay();
 #endif
 
-    if (auto milestones = layerTreeTransaction.newlyReachedLayoutMilestones())
+    if (auto milestones = layerTreeTransaction.newlyReachedPaintingMilestones())
         m_webPageProxy.didReachLayoutMilestone(milestones);
 
     for (auto& callbackID : layerTreeTransaction.callbackIDs()) {
index 7c56ca0..8069a15 100644 (file)
@@ -132,7 +132,7 @@ public:
 
     virtual void setShouldScaleViewToFitDocument(bool) { }
 
-    virtual bool dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) { return false; }
+    virtual bool addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone>) { return false; }
 
 #if PLATFORM(COCOA)
     // Used by TiledCoreAnimationDrawingArea.
index 271dc33..433159f 100644 (file)
@@ -109,7 +109,7 @@ private:
 
     bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
 
-    bool dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) override;
+    bool addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone>) override;
 
     void updateScrolledExposedRect();
     void updateRootLayers();
@@ -173,12 +173,18 @@ private:
     Vector<RemoteLayerTreeTransaction::TransactionCallbackID> m_pendingCallbackIDs;
     ActivityStateChangeID m_activityStateChangeID { ActivityStateChangeAsynchronous };
 
-    OptionSet<WebCore::LayoutMilestone> m_pendingNewlyReachedLayoutMilestones;
+    OptionSet<WebCore::LayoutMilestone> m_pendingNewlyReachedPaintingMilestones;
 
     RefPtr<WebCore::GraphicsLayer> m_contentLayer;
     RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer;
 };
 
+inline bool RemoteLayerTreeDrawingArea::addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone> paintMilestones)
+{
+    m_pendingNewlyReachedPaintingMilestones.add(paintMilestones);
+    return true;
+}
+
 } // namespace WebKit
 
 SPECIALIZE_TYPE_TRAITS_DRAWING_AREA(RemoteLayerTreeDrawingArea, DrawingAreaTypeRemoteLayerTree)
index 8c43f33..b752c1c 100644 (file)
@@ -390,8 +390,8 @@ void RemoteLayerTreeDrawingArea::flushLayers()
     backingStoreCollection.willCommitLayerTree(layerTransaction);
     m_webPage.willCommitLayerTree(layerTransaction);
 
-    layerTransaction.setNewlyReachedLayoutMilestones(m_pendingNewlyReachedLayoutMilestones);
-    m_pendingNewlyReachedLayoutMilestones = { };
+    layerTransaction.setNewlyReachedPaintingMilestones(m_pendingNewlyReachedPaintingMilestones);
+    m_pendingNewlyReachedPaintingMilestones = { };
 
     layerTransaction.setActivityStateChangeID(m_activityStateChangeID);
     m_activityStateChangeID = ActivityStateChangeAsynchronous;
@@ -532,12 +532,6 @@ void RemoteLayerTreeDrawingArea::addTransactionCallbackID(CallbackID callbackID)
     scheduleCompositingLayerFlush();
 }
 
-bool RemoteLayerTreeDrawingArea::dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone> layoutMilestones)
-{
-    m_pendingNewlyReachedLayoutMilestones.add(layoutMilestones);
-    return true;
-}
-
 void RemoteLayerTreeDrawingArea::adoptLayersFromDrawingArea(DrawingArea& oldDrawingArea)
 {
     RELEASE_ASSERT(oldDrawingArea.type() == type());
index c12305e..a0940d2 100644 (file)
@@ -6225,8 +6225,12 @@ void WebPage::dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone
     ASSERT(!userData);
 
     // The drawing area might want to defer dispatch of didLayout to the UI process.
-    if (m_drawingArea && m_drawingArea->dispatchDidReachLayoutMilestone(milestones))
-        return;
+    if (m_drawingArea) {
+        static auto paintMilestones = OptionSet<WebCore::LayoutMilestone> { DidHitRelevantRepaintedObjectsAreaThreshold, DidFirstFlushForHeaderLayer, DidFirstPaintAfterSuppressedIncrementalRendering, DidRenderSignificantAmountOfText, DidFirstMeaningfulPaint };   
+        auto drawingAreaRelatedMilestones = milestones & paintMilestones;
+        if (drawingAreaRelatedMilestones && m_drawingArea->addMilestonesToDispatch(drawingAreaRelatedMilestones))
+            milestones.remove(drawingAreaRelatedMilestones);
+    }
 
     send(Messages::WebPageProxy::DidReachLayoutMilestone(milestones));
 }
index 9762fc0..9af1e7f 100644 (file)
@@ -86,7 +86,7 @@ private:
 
     void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
 
-    bool dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) override;
+    bool addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone> paintMilestones) override;
 
     enum class FlushType { Normal, TransientZoom };
     void flushLayers(FlushType = FlushType::Normal);
@@ -125,7 +125,7 @@ private:
     void updateScrolledExposedRect();
     void scaleViewToFitDocumentIfNeeded();
 
-    void sendPendingNewlyReachedLayoutMilestones();
+    void sendPendingNewlyReachedPaintingMilestones();
 
     void layerFlushRunLoopCallback();
     void invalidateLayerFlushRunLoopObserver();
@@ -163,7 +163,7 @@ private:
 
     RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer;
 
-    OptionSet<WebCore::LayoutMilestone> m_pendingNewlyReachedLayoutMilestones;
+    OptionSet<WebCore::LayoutMilestone> m_pendingNewlyReachedPaintingMilestones;
     Vector<CallbackID> m_pendingCallbackIDs;
 
     std::unique_ptr<WebCore::RunLoopObserver> m_layerFlushRunLoopObserver;
@@ -178,6 +178,12 @@ private:
     bool m_needsSendEnterAcceleratedCompositingMode { true };
 };
 
+inline bool TiledCoreAnimationDrawingArea::addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone> paintMilestones)
+{
+    m_pendingNewlyReachedPaintingMilestones.add(paintMilestones);
+    return true;
+}
+
 } // namespace WebKit
 
 SPECIALIZE_TYPE_TRAITS_DRAWING_AREA(TiledCoreAnimationDrawingArea, DrawingAreaTypeTiledCoreAnimation)
index a4b9fa5..85f0ca2 100644 (file)
@@ -436,13 +436,13 @@ void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(W
 #endif
 }
 
-void TiledCoreAnimationDrawingArea::sendPendingNewlyReachedLayoutMilestones()
+void TiledCoreAnimationDrawingArea::sendPendingNewlyReachedPaintingMilestones()
 {
-    if (!m_pendingNewlyReachedLayoutMilestones)
+    if (!m_pendingNewlyReachedPaintingMilestones)
         return;
 
-    m_webPage.send(Messages::WebPageProxy::DidReachLayoutMilestone(m_pendingNewlyReachedLayoutMilestones));
-    m_pendingNewlyReachedLayoutMilestones = { };
+    m_webPage.send(Messages::WebPageProxy::DidReachLayoutMilestone(m_pendingNewlyReachedPaintingMilestones));
+    m_pendingNewlyReachedPaintingMilestones = { };
 }
 
 void TiledCoreAnimationDrawingArea::addTransactionCallbackID(CallbackID callbackID)
@@ -484,7 +484,7 @@ void TiledCoreAnimationDrawingArea::flushLayers(FlushType flushType)
                     corePage->inspectorController().didComposite(*coreFrame);
             }
             if (auto drawingArea = static_cast<TiledCoreAnimationDrawingArea*>(retainedPage->drawingArea()))
-                drawingArea->sendPendingNewlyReachedLayoutMilestones();
+                drawingArea->sendPendingNewlyReachedPaintingMilestones();
         } forPhase:kCATransactionPhasePostCommit];
 
         bool didFlushAllFrames = m_webPage.mainFrameView()->flushCompositingStateIncludingSubframes();
@@ -931,12 +931,6 @@ void TiledCoreAnimationDrawingArea::addFence(const MachSendRight& fencePort)
     m_layerHostingContext->setFencePort(fencePort.sendRight());
 }
 
-bool TiledCoreAnimationDrawingArea::dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone> layoutMilestones)
-{
-    m_pendingNewlyReachedLayoutMilestones.add(layoutMilestones);
-    return true;
-}
-
 void TiledCoreAnimationDrawingArea::layerFlushRunLoopCallback()
 {
     flushLayers();