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

Changeset 242624 in webkit


Ignore:
Timestamp:
Mar 7, 2019, 4:52:57 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

requestAnimationFrame should execute before the next frame
https://bugs.webkit.org/show_bug.cgi?id=177484

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-03-07
Reviewed by Simon Fraser.

Source/WebCore:

This change fixes two issues with animation timing:

  1. Calling the requestAnimationFrame callbacks would have happened when the DisplayLink fires. This may have happened even if the frame is missed and no display is committed.
  1. Style changes and layout triggered by script could trigger painting at more than 60fps. CoreAnimation commits could happen at more than 60fps, although WindowServer will throttle those, and only some will be shown on the screen.

This change introduces a new paint scheduling model where painting is
driven by a "RenderingUpdateScheduler", which only triggers paints once
per 16.7ms frame.

Code that previously scheduled a compositing layer flush now schedules a
"RenderingUpdate", and that update is driven by a DisplayRefreshMonitor
callback. When the render happens, we service requestAnimationFrame callbacks,
Web Animations and intersection observations per the "Update the rendering"
step of the HTML Event Loop specification
<https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.

In the future, more rendering steps will be added to this code.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • accessibility/mac/AXObjectCacheMac.mm:

Fix layout tests by adding null check.

  • animation/DocumentAnimationScheduler.cpp: Removed.
  • animation/DocumentAnimationScheduler.h: Removed.
  • animation/DocumentTimeline.cpp:

(WebCore::DocumentTimeline::DocumentTimeline):
(WebCore::DocumentTimeline::updateThrottlingState):
(WebCore::DocumentTimeline::resumeAnimations):
(WebCore::DocumentTimeline::liveCurrentTime const):
(WebCore::DocumentTimeline::currentTime):
(WebCore::DocumentTimeline::animationTimingDidChange):
(WebCore::DocumentTimeline::scheduleAnimationResolution):
(WebCore::DocumentTimeline::unscheduleAnimationResolution):
(WebCore::DocumentTimeline::updateAnimationsAndSendEvents):
(WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents):
(WebCore::DocumentTimeline::scheduleNextTick):
(WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement):
Simplify this function by handling the case of no-animations separately.

(WebCore::DocumentTimeline::resolveAnimationsForElement):
Simplify the loop and delete hasPendingAcceleratedAnimations because it
is initialized to true and is not changed inside the loop.

(WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Deleted.
(WebCore::DocumentTimeline::animationResolutionTimerFired): Deleted.

  • animation/DocumentTimeline.h:
  • dom/Document.cpp:

(WebCore::Document::resolveStyle):
There is no need to force update in resolveStyle(). notifyFlushRequired()
will be called eventually which will scheduleRenderingUpdate().

(WebCore::Document::prepareForDestruction):
(WebCore::Document::updateAnimationsAndSendEvents):
(WebCore::Document::serviceRequestAnimationFrameCallbacks):
(WebCore::Document::windowScreenDidChange):
(WebCore::Document::updateIntersectionObservations):
(WebCore::Document::scheduleForcedIntersectionObservationUpdate): Deleted.
(WebCore::Document::animationScheduler): Deleted.

  • dom/Document.h:

(WebCore::Document::numberOfIntersectionObservers const):

  • dom/ScriptedAnimationController.cpp:

(WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
(WebCore::ScriptedAnimationController::scheduleAnimation):
(WebCore::ScriptedAnimationController::animationTimerFired):
(WebCore::ScriptedAnimationController::serviceScriptedAnimations): Deleted.
(WebCore::ScriptedAnimationController::documentAnimationSchedulerDidFire): Deleted.

  • dom/ScriptedAnimationController.h:
  • page/FrameView.cpp:

(WebCore::FrameView::viewportContentsChanged):

  • page/IntersectionObserver.cpp:

(WebCore::IntersectionObserver::observe):

  • page/Page.cpp:

(WebCore::Page::Page):
(WebCore::Page::layoutIfNeeded):
(WebCore::Page::renderingUpdate):
(WebCore::Page::renderingUpdateScheduler):
(WebCore::Page::willDisplayPage): Deleted.
(WebCore::Page::addDocumentNeedingIntersectionObservationUpdate): Deleted.
(WebCore::Page::updateIntersectionObservations): Deleted.
(WebCore::Page::scheduleForcedIntersectionObservationUpdate): Deleted.

  • page/Page.h:
  • page/PageOverlayController.cpp:

(WebCore::PageOverlayController::didChangeViewExposedRect):
(WebCore::PageOverlayController::notifyFlushRequired):

  • page/ResourceUsageData.h:

Include header files that become missing because of adding
RenderingUpdateScheduler.cpp.

  • page/RenderingUpdateScheduler.cpp: Added.

(WebCore::RenderingUpdateScheduler::RenderingUpdateScheduler):
(WebCore::RenderingUpdateScheduler::scheduleRenderingUpdate):
(WebCore::RenderingUpdateScheduler::startTimer):
(WebCore::RenderingUpdateScheduler::clearTimer):
(WebCore::RenderingUpdateScheduler::windowScreenDidChange):
(WebCore::RenderingUpdateScheduler::createDisplayRefreshMonitor const):
(WebCore::RenderingUpdateScheduler::displayRefreshFired):

  • page/RenderingUpdateScheduler.h: Added.

(WebCore::RenderingUpdateScheduler::create):

  • page/ios/ContentChangeObserver.h:

Include header files that become missing because of adding
RenderingUpdateScheduler.cpp.

  • page/mac/ServicesOverlayController.mm:

(WebCore::ServicesOverlayController::Highlight::notifyFlushRequired):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::scheduleLayerFlushNow):

Source/WebKit:

Replace the calls to Page::layoutIfNeeded() and willDisplayPage() by
a single call to Page::renderingUpdate(). This new function implements
"Update the rendering" step of the HTML Event Loop specification
<https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.

  • WebProcess/WebPage/AcceleratedDrawingArea.cpp:

(WebKit::AcceleratedDrawingArea::updateBackingStoreState):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:

(WebKit::LayerTreeHost::layerFlushTimerFired):

  • WebProcess/WebPage/DrawingAreaImpl.cpp:

(WebKit::DrawingAreaImpl::display):

  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:

(WebKit::RemoteLayerTreeDrawingArea::flushLayers):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::layoutIfNeeded):
(WebKit::WebPage::renderingUpdate):
(WebKit::WebPage::willDisplayPage): Deleted.

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

(WebKit::TiledCoreAnimationDrawingArea::flushLayers):

Source/WebKitLegacy/mac:

  • WebView/WebView.mm:

(-[WebView _viewWillDrawInternal]):
Call Page::renderingUpdate() which implements "Update the rendering"
step of the HTML Event Loop specification.

Source/WebKitLegacy/win:

  • WebView.cpp:

(WebView::updateBackingStore):
(WebView::flushPendingGraphicsLayerChangesSoon):
(WebView::flushPendingGraphicsLayerChanges):
Call Page::renderingUpdate() which implements "Update the rendering"
step of the HTML Event Loop specification.

Source/WTF:

Add trace points for the page RenderingUpdate.

  • wtf/SystemTracing.h:

Tools:

Add trace points for the page RenderingUpdate.

  • Tracing/SystemTracePoints.plist:

LayoutTests:

There is a slight difference between the actual DRT and the expected DRT
due to animation timing change. But these two tests are not animating
correctly if they are opened in Safari with web animation turned on.

  • animations/animation-multiple-callbacks-timestamp.html:

Fix variable names used by an error message.

  • animations/no-style-recalc-during-accelerated-animation-expected.txt:
  • animations/no-style-recalc-during-accelerated-animation.html:

One extra styleReclc was incurred due to the document styleRecalcTimer.
I think this timer is not needed anymore. I will look at removing it in
a separate patch.

Location:
trunk
Files:
1 added
1 deleted
38 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r242621 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestExpectations:
     9        There is a slight difference between the actual DRT and the expected DRT
     10        due to animation timing change. But these two tests are not animating
     11        correctly if they are opened in Safari with web animation turned on.
     12
     13        * animations/animation-multiple-callbacks-timestamp.html:
     14        Fix variable names used by an error message.
     15        * animations/no-style-recalc-during-accelerated-animation-expected.txt:
     16        * animations/no-style-recalc-during-accelerated-animation.html:
     17        One extra styleReclc was incurred due to the document styleRecalcTimer.
     18        I think this timer is not needed anymore. I will look at removing it in
     19        a separate patch.
     20
    1212019-03-07  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/LayoutTests/TestExpectations

    r242612 r242624  
    30393039# This is fallout from turning Web Animations on.
    30403040webkit.org/b/190032 animations/animation-playstate-paused-style-resolution.html [ Failure ]
     3041webkit.org/b/190032 animations/missing-values-first-keyframe.html [ Failure ]
     3042webkit.org/b/190032 animations/missing-values-last-keyframe.html [ Failure ]
    30413043webkit.org/b/190032 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Failure ]
    30423044webkit.org/b/190032 compositing/backing/transform-transition-from-outside-view.html [ Failure ]
  • trunk/LayoutTests/animations/animation-multiple-callbacks-timestamp.html

    r202399 r242624  
    3636            const WarmupFrames = 5;
    3737            if (++currentFrame > WarmupFrames && timestamp != timestamp1) {
    38                 testFailed("timestamp1 = " + timestamp1 + ", timestamp2 = " + timestamp2  + ", window.performance.now() = " + window.performance.now());
     38                testFailed("timestamp = " + timestamp + ", timestamp1 = " + timestamp1  + ", window.performance.now() = " + window.performance.now());
    3939                failed = true;
    4040            }
  • trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt

    r238128 r242624  
    11Got iteration event.
    2 PASS: saw two or fewer style recalcs during the animation.
     2PASS: saw three or fewer style recalcs during the animation.
  • trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation.html

    r238128 r242624  
    3636            box.addEventListener("animationend", () => {
    3737                const numRecalcs = internals.styleRecalcCount();
    38                 if (numRecalcs > 2)
    39                     result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see two."
     38                if (numRecalcs > 3)
     39                    result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see three."
    4040                else
    41                     result.innerText += "PASS: saw two or fewer style recalcs during the animation."
     41                    result.innerText += "PASS: saw three or fewer style recalcs during the animation."
    4242
    4343                if (window.testRunner)
  • trunk/Source/WTF/ChangeLog

    r242592 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add trace points for the page RenderingUpdate.
     9
     10        * wtf/SystemTracing.h:
     11
    1122019-03-06  Ross Kirsling  <ross.kirsling@sony.com>
    213
  • trunk/Source/WTF/wtf/SystemTracing.h

    r242294 r242624  
    7878    ComputeEventRegionsEnd,
    7979
     80    ScheduleRenderingUpdate,
     81    TriggerRenderingUpdate,
     82    RenderingUpdateStart,
     83    RenderingUpdateEnd,
     84
    8085    WebKitRange = 10000,
    8186    WebHTMLViewPaintStart,
  • trunk/Source/WebCore/ChangeLog

    r242621 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        This change fixes two issues with animation timing:
     9
     10        1. Calling the requestAnimationFrame callbacks would have happened when
     11           the DisplayLink fires. This may have happened even if the frame is
     12           missed and no display is committed.
     13
     14        2. Style changes and layout triggered by script could trigger painting
     15           at more than 60fps. CoreAnimation commits could happen at more than
     16           60fps, although WindowServer will throttle those, and only some will
     17           be shown on the screen.
     18
     19        This change introduces a new paint scheduling model where painting is
     20        driven by a "RenderingUpdateScheduler", which only triggers paints once
     21        per 16.7ms frame.
     22
     23        Code that previously scheduled a compositing layer flush now schedules a
     24        "RenderingUpdate", and that update is driven by a DisplayRefreshMonitor
     25        callback. When the render happens, we service requestAnimationFrame callbacks,
     26        Web Animations and intersection observations per the "Update the rendering"
     27        step of the HTML Event Loop specification
     28        <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.
     29
     30        In the future, more rendering steps will be added to this code.
     31
     32        * Sources.txt:
     33        * WebCore.xcodeproj/project.pbxproj:
     34        * accessibility/mac/AXObjectCacheMac.mm:
     35        Fix layout tests by adding null check.
     36
     37        * animation/DocumentAnimationScheduler.cpp: Removed.
     38        * animation/DocumentAnimationScheduler.h: Removed.
     39        * animation/DocumentTimeline.cpp:
     40        (WebCore::DocumentTimeline::DocumentTimeline):
     41        (WebCore::DocumentTimeline::updateThrottlingState):
     42        (WebCore::DocumentTimeline::resumeAnimations):
     43        (WebCore::DocumentTimeline::liveCurrentTime const):
     44        (WebCore::DocumentTimeline::currentTime):
     45        (WebCore::DocumentTimeline::animationTimingDidChange):
     46        (WebCore::DocumentTimeline::scheduleAnimationResolution):
     47        (WebCore::DocumentTimeline::unscheduleAnimationResolution):
     48        (WebCore::DocumentTimeline::updateAnimationsAndSendEvents):
     49        (WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents):
     50        (WebCore::DocumentTimeline::scheduleNextTick):
     51        (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement):
     52        Simplify this function by handling the case of no-animations separately.
     53
     54        (WebCore::DocumentTimeline::resolveAnimationsForElement):
     55        Simplify the loop and delete hasPendingAcceleratedAnimations because it
     56        is initialized to true and is not changed inside the loop.
     57
     58        (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Deleted.
     59        (WebCore::DocumentTimeline::animationResolutionTimerFired): Deleted.
     60        * animation/DocumentTimeline.h:
     61        * dom/Document.cpp:
     62        (WebCore::Document::resolveStyle):
     63        There is no need to force update in resolveStyle(). notifyFlushRequired()
     64        will be called eventually which will scheduleRenderingUpdate().
     65
     66        (WebCore::Document::prepareForDestruction):
     67        (WebCore::Document::updateAnimationsAndSendEvents):
     68        (WebCore::Document::serviceRequestAnimationFrameCallbacks):
     69        (WebCore::Document::windowScreenDidChange):
     70        (WebCore::Document::updateIntersectionObservations):
     71        (WebCore::Document::scheduleForcedIntersectionObservationUpdate): Deleted.
     72        (WebCore::Document::animationScheduler): Deleted.
     73        * dom/Document.h:
     74        (WebCore::Document::numberOfIntersectionObservers const):
     75        * dom/ScriptedAnimationController.cpp:
     76        (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
     77        (WebCore::ScriptedAnimationController::scheduleAnimation):
     78        (WebCore::ScriptedAnimationController::animationTimerFired):
     79        (WebCore::ScriptedAnimationController::serviceScriptedAnimations): Deleted.
     80        (WebCore::ScriptedAnimationController::documentAnimationSchedulerDidFire): Deleted.
     81        * dom/ScriptedAnimationController.h:
     82        * page/FrameView.cpp:
     83        (WebCore::FrameView::viewportContentsChanged):
     84        * page/IntersectionObserver.cpp:
     85        (WebCore::IntersectionObserver::observe):
     86        * page/Page.cpp:
     87        (WebCore::Page::Page):
     88        (WebCore::Page::layoutIfNeeded):
     89        (WebCore::Page::renderingUpdate):
     90        (WebCore::Page::renderingUpdateScheduler):
     91        (WebCore::Page::willDisplayPage): Deleted.
     92        (WebCore::Page::addDocumentNeedingIntersectionObservationUpdate): Deleted.
     93        (WebCore::Page::updateIntersectionObservations): Deleted.
     94        (WebCore::Page::scheduleForcedIntersectionObservationUpdate): Deleted.
     95        * page/Page.h:
     96        * page/PageOverlayController.cpp:
     97        (WebCore::PageOverlayController::didChangeViewExposedRect):
     98        (WebCore::PageOverlayController::notifyFlushRequired):
     99        * page/ResourceUsageData.h:
     100        Include header files that become missing because of adding
     101        RenderingUpdateScheduler.cpp.
     102
     103        * page/RenderingUpdateScheduler.cpp: Added.
     104        (WebCore::RenderingUpdateScheduler::RenderingUpdateScheduler):
     105        (WebCore::RenderingUpdateScheduler::scheduleRenderingUpdate):
     106        (WebCore::RenderingUpdateScheduler::startTimer):
     107        (WebCore::RenderingUpdateScheduler::clearTimer):
     108        (WebCore::RenderingUpdateScheduler::windowScreenDidChange):
     109        (WebCore::RenderingUpdateScheduler::createDisplayRefreshMonitor const):
     110        (WebCore::RenderingUpdateScheduler::displayRefreshFired):
     111        * page/RenderingUpdateScheduler.h: Added.
     112        (WebCore::RenderingUpdateScheduler::create):
     113        * page/ios/ContentChangeObserver.h:
     114        Include header files that become missing because of adding
     115        RenderingUpdateScheduler.cpp.
     116
     117        * page/mac/ServicesOverlayController.mm:
     118        (WebCore::ServicesOverlayController::Highlight::notifyFlushRequired):
     119        * rendering/RenderLayerCompositor.cpp:
     120        (WebCore::RenderLayerCompositor::scheduleLayerFlushNow):
     121
    11222019-03-07  Zalan Bujtas  <zalan@apple.com>
    2123
  • trunk/Source/WebCore/Sources.txt

    r242615 r242624  
    421421animation/CSSTransition.cpp
    422422animation/DeclarativeAnimation.cpp
    423 animation/DocumentAnimationScheduler.cpp
    424423animation/DocumentTimeline.cpp
    425424animation/KeyframeEffect.cpp
     
    15401539page/RemoteDOMWindow.cpp
    15411540page/RemoteFrame.cpp
     1541page/RenderingUpdateScheduler.cpp
    15421542page/ResourceUsageOverlay.cpp
    15431543page/ResourceUsageThread.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r242615 r242624  
    17811781                555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17821782                555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
     1783                556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17831784                5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17841785                55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    21182119                715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21192120                715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; };
    2120                 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21212121                71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21222122                71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; };
     
    86448644                555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
    86458645                555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
     8646                556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderingUpdateScheduler.h; sourceTree = "<group>"; };
     8647                556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderingUpdateScheduler.cpp; sourceTree = "<group>"; };
    86468648                5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; };
    86478649                5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
     
    93709372                716C8DF31E48B284005BD0DA /* volume-down-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-down-button.js"; sourceTree = "<group>"; };
    93719373                716C8DF41E48B284005BD0DA /* volume-up-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-button.js"; sourceTree = "<group>"; };
    9372                 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentAnimationScheduler.h; sourceTree = "<group>"; };
    9373                 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentAnimationScheduler.cpp; sourceTree = "<group>"; };
    93749374                716FA0D81DB26591007323CC /* airplay-button.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "airplay-button.css"; sourceTree = "<group>"; };
    93759375                716FA0D91DB26591007323CC /* airplay-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-button.js"; sourceTree = "<group>"; };
     
    2049620496                                46B9518C207D632900A7D2DD /* RemoteFrame.cpp */,
    2049720497                                46B95192207D632E00A7D2DD /* RemoteFrame.h */,
     20498                                556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */,
     20499                                556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */,
    2049820500                                A5071E821C56D079009951BE /* ResourceUsageData.h */,
    2049920501                                ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
     
    2064820650                                715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */,
    2064920651                                715AD71D2050512400D592DC /* DeclarativeAnimation.h */,
    20650                                 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */,
    20651                                 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */,
    2065220652                                71025EC41F99F096004A250C /* DocumentTimeline.cpp */,
    2065320653                                71025EC51F99F096004A250C /* DocumentTimeline.h */,
     
    2907229072                                7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */,
    2907329073                                A8185F4009765766005826D9 /* Document.h in Headers */,
    29074                                 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */,
    2907529074                                A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */,
    2907629075                                A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
     
    3127431273                                08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */,
    3127531274                                08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */,
     31275                                556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */,
    3127631276                                BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */,
    3127731277                                B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */,
  • trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm

    r241721 r242624  
    540540    NSAccessibilityHandleFocusChanged();
    541541    // AXFocusChanged is a test specific notification name and not something a real AT will be listening for
    542     if (UNLIKELY(axShouldRepostNotificationsForTests))
    543         [rootWebArea()->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil];
     542    if (UNLIKELY(!axShouldRepostNotificationsForTests))
     543        return;
     544
     545    auto* rootWebArea = this->rootWebArea();
     546    if (!rootWebArea)
     547        return;
     548
     549    [rootWebArea->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil];
    544550}
    545551
  • trunk/Source/WebCore/animation/DocumentTimeline.cpp

    r239820 r242624  
    3434#include "DeclarativeAnimation.h"
    3535#include "Document.h"
    36 #include "DocumentAnimationScheduler.h"
    3736#include "GraphicsLayer.h"
    3837#include "KeyframeEffect.h"
     
    6261DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime)
    6362    : AnimationTimeline()
    64 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    65     , m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired)
    66 #endif
    67     , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolutionIfNeeded)
     63    , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolution)
    6864    , m_document(&document)
    6965    , m_originTime(originTime)
     
    195191void DocumentTimeline::updateThrottlingState()
    196192{
    197     scheduleAnimationResolutionIfNeeded();
     193    scheduleAnimationResolution();
    198194}
    199195
     
    211207
    212208    if (!m_cachedCurrentTime)
    213         m_cachedCurrentTime = liveCurrentTime();
     209        m_cachedCurrentTime = Seconds(liveCurrentTime());
    214210
    215211    for (const auto& animation : m_animations)
     
    235231        animation->setSuspended(false);
    236232
    237     scheduleAnimationResolutionIfNeeded();
     233    scheduleAnimationResolution();
    238234}
    239235
     
    253249}
    254250
    255 Seconds DocumentTimeline::liveCurrentTime() const
    256 {
    257 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    258     return m_document->animationScheduler().lastTimestamp();
    259 #else
    260     return Seconds(m_document->domWindow()->nowTimestamp());
    261 #endif
     251DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const
     252{
     253    return m_document->domWindow()->nowTimestamp();
    262254}
    263255
     
    275267    }
    276268
    277     auto currentTime = liveCurrentTime();
    278 
    279 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    280     // If we're in the middle of firing a frame, either due to a requestAnimationFrame callback
    281     // or scheduling an animation update, we want to ensure we use the same time we're using as
    282     // the timestamp for requestAnimationFrame() callbacks.
    283     if (m_document->animationScheduler().isFiring())
    284         cacheCurrentTime(currentTime);
    285 #endif
    286 
    287     if (!m_cachedCurrentTime) {
    288 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    289         // If we're not in the middle of firing a frame, let's make our best guess at what the currentTime should
    290         // be since the last time a frame fired by increment of our update interval. This way code using something
    291         // like setTimeout() or handling events will get a time that's only updating at around 60fps, or less if
    292         // we're throttled.
    293         auto lastAnimationSchedulerTimestamp = currentTime;
    294         auto delta = Seconds(m_document->domWindow()->nowTimestamp()) - lastAnimationSchedulerTimestamp;
    295         int frames = std::floor(delta.seconds() / animationInterval().seconds());
    296         cacheCurrentTime(lastAnimationSchedulerTimestamp + Seconds(frames * animationInterval().seconds()));
    297 #else
    298         cacheCurrentTime(currentTime);
    299 #endif
    300     }
     269    if (!m_cachedCurrentTime)
     270        cacheCurrentTime(liveCurrentTime());
     271   
    301272    return m_cachedCurrentTime.value() - m_originTime;
    302273}
    303274
    304 void DocumentTimeline::cacheCurrentTime(Seconds newCurrentTime)
    305 {
    306     m_cachedCurrentTime = newCurrentTime;
     275void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime)
     276{
     277    m_cachedCurrentTime = Seconds(newCurrentTime);
    307278    // We want to be sure to keep this time cached until we've both finished running JS and finished updating
    308279    // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
     
    327298}
    328299
    329 void DocumentTimeline::scheduleAnimationResolutionIfNeeded()
    330 {
    331     if (!m_isUpdatingAnimations && !m_isSuspended && !m_animations.isEmpty())
    332         scheduleAnimationResolution();
    333 }
    334 
    335300void DocumentTimeline::animationTimingDidChange(WebAnimation& animation)
    336301{
    337302    AnimationTimeline::animationTimingDidChange(animation);
    338     scheduleAnimationResolutionIfNeeded();
     303    scheduleAnimationResolution();
    339304}
    340305
     
    349314void DocumentTimeline::scheduleAnimationResolution()
    350315{
    351 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    352     m_document->animationScheduler().scheduleWebAnimationsResolution();
    353 #else
    354     // FIXME: We need to use the same logic as ScriptedAnimationController here,
    355     // which will be addressed by the refactor tracked by webkit.org/b/179293.
    356     m_animationResolutionTimer.startOneShot(animationInterval());
    357 #endif
     316    if (m_isSuspended || m_animations.isEmpty() || m_animationResolutionScheduled)
     317        return;
     318
     319    if (!m_document || !m_document->page())
     320        return;
     321   
     322    m_document->page()->renderingUpdateScheduler().scheduleRenderingUpdate();
     323    m_animationResolutionScheduled = true;
    358324}
    359325
     
    361327{
    362328    m_tickScheduleTimer.stop();
    363 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    364     m_document->animationScheduler().unscheduleWebAnimationsResolution();
    365 #else
    366     // FIXME: We need to use the same logic as ScriptedAnimationController here,
    367     // which will be addressed by the refactor tracked by webkit.org/b/179293.
    368     m_animationResolutionTimer.stop();
    369 #endif
    370 }
    371 
    372 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    373 void DocumentTimeline::documentAnimationSchedulerDidFire()
    374 #else
    375 void DocumentTimeline::animationResolutionTimerFired()
    376 #endif
    377 {
    378     updateAnimationsAndSendEvents();
     329    m_animationResolutionScheduled = false;
     330}
     331
     332void DocumentTimeline::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
     333{
     334    // We need to freeze the current time even if no animation is running.
     335    // document.timeline.currentTime may be called from a rAF callback and
     336    // it has to match the rAF timestamp.
     337    if (!m_isSuspended)
     338        cacheCurrentTime(timestamp);
     339
     340    if (m_isSuspended || m_animations.isEmpty() || !m_animationResolutionScheduled)
     341        return;
     342
     343    internalUpdateAnimationsAndSendEvents();
    379344    applyPendingAcceleratedAnimations();
     345
     346    m_animationResolutionScheduled = false;
    380347    scheduleNextTick();
    381348}
    382349
    383 void DocumentTimeline::updateAnimationsAndSendEvents()
     350void DocumentTimeline::internalUpdateAnimationsAndSendEvents()
    384351{
    385352    m_numberOfAnimationTimelineInvalidationsForTesting++;
    386 
    387     m_isUpdatingAnimations = true;
    388353
    389354    // https://drafts.csswg.org/web-animations/#update-animations-and-send-events
     
    449414    for (auto& completedTransition : completedTransitions)
    450415        transitionDidComplete(completedTransition);
    451 
    452     m_isUpdatingAnimations = false;
    453416}
    454417
     
    474437    for (const auto& animation : m_animations) {
    475438        if (!animation->isRunningAccelerated()) {
    476             scheduleAnimationResolutionIfNeeded();
     439            scheduleAnimationResolution();
    477440            return;
    478441        }
     
    484447        auto animationTimeToNextRequiredTick = animation->timeToNextTick();
    485448        if (animationTimeToNextRequiredTick < animationInterval()) {
    486             scheduleAnimationResolutionIfNeeded();
     449            scheduleAnimationResolution();
    487450            return;
    488451        }
     
    594557{
    595558    auto animations = animationsForElement(element);
    596     bool runningAnimationsForElementAreAllAccelerated = !animations.isEmpty();
     559
     560    if (animations.isEmpty()) {
     561        m_elementsWithRunningAcceleratedAnimations.remove(&element);
     562        return;
     563    }
     564
    597565    for (const auto& animation : animations) {
    598566        if (!animation->isRunningAccelerated()) {
    599             runningAnimationsForElementAreAllAccelerated = false;
    600             break;
    601         }
    602     }
    603 
    604     if (runningAnimationsForElementAreAllAccelerated)
    605         m_elementsWithRunningAcceleratedAnimations.add(&element);
    606     else
    607         m_elementsWithRunningAcceleratedAnimations.remove(&element);
     567            m_elementsWithRunningAcceleratedAnimations.remove(&element);
     568            return;
     569        }
     570    }
     571
     572    m_elementsWithRunningAcceleratedAnimations.add(&element);
    608573}
    609574
     
    626591bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle)
    627592{
    628     bool hasNonAcceleratedAnimations = false;
    629     bool hasPendingAcceleratedAnimations = true;
     593    bool hasNonAcceleratedAnimationProperty = false;
     594
    630595    for (const auto& animation : animationsForElement(element)) {
    631596        animation->resolve(targetStyle);
    632         if (!hasNonAcceleratedAnimations) {
    633             if (auto* effect = animation->effect()) {
    634                 if (is<KeyframeEffect>(effect)) {
    635                     auto* keyframeEffect = downcast<KeyframeEffect>(effect);
    636                     for (auto cssPropertyId : keyframeEffect->animatedProperties()) {
    637                         if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {
    638                             hasNonAcceleratedAnimations = true;
    639                             continue;
    640                         }
    641                         if (!hasPendingAcceleratedAnimations)
    642                             hasPendingAcceleratedAnimations = keyframeEffect->hasPendingAcceleratedAction();
    643                     }
    644                 }
     597
     598        if (hasNonAcceleratedAnimationProperty)
     599            continue;
     600
     601        auto* effect = animation->effect();
     602        if (!effect || !is<KeyframeEffect>(effect))
     603            continue;
     604
     605        auto* keyframeEffect = downcast<KeyframeEffect>(effect);
     606        for (auto cssPropertyId : keyframeEffect->animatedProperties()) {
     607            if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {
     608                hasNonAcceleratedAnimationProperty = true;
     609                break;
    645610            }
    646611        }
    647612    }
    648613
    649     // If there are no non-accelerated animations and we've encountered at least one pending
    650     // accelerated animation, we should recomposite this element's layer for animation purposes.
    651     return !hasNonAcceleratedAnimations && hasPendingAcceleratedAnimations;
     614    return !hasNonAcceleratedAnimationProperty;
    652615}
    653616
  • trunk/Source/WebCore/animation/DocumentTimeline.h

    r239820 r242624  
    7272
    7373    void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
    74 
    75 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    76     void documentAnimationSchedulerDidFire();
    77 #endif
     74   
     75    void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
    7876
    7977    void updateThrottlingState();
     
    8987    DocumentTimeline(Document&, Seconds);
    9088
    91     Seconds liveCurrentTime() const;
    92     void cacheCurrentTime(Seconds);
    93     void scheduleAnimationResolutionIfNeeded();
     89    DOMHighResTimeStamp liveCurrentTime() const;
     90    void cacheCurrentTime(DOMHighResTimeStamp);
     91    void maybeClearCachedCurrentTime();
    9492    void scheduleInvalidationTaskIfNeeded();
    9593    void performInvalidationTask();
    96     void animationScheduleTimerFired();
    9794    void scheduleAnimationResolution();
    9895    void unscheduleAnimationResolution();
    99     void updateAnimationsAndSendEvents();
     96    void internalUpdateAnimationsAndSendEvents();
    10097    void performEventDispatchTask();
    101     void maybeClearCachedCurrentTime();
    10298    void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&);
    10399    void transitionDidComplete(RefPtr<CSSTransition>);
    104100    void scheduleNextTick();
    105 
    106 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    107     void animationResolutionTimerFired();
    108     Timer m_animationResolutionTimer;
    109 #endif
    110101
    111102    Timer m_tickScheduleTimer;
     
    120111    bool m_isSuspended { false };
    121112    bool m_waitingOnVMIdle { false };
    122     bool m_isUpdatingAnimations { false };
     113    bool m_animationResolutionScheduled { false };
    123114};
    124115
  • trunk/Source/WebCore/dom/Document.cpp

    r242340 r242624  
    5858#include "DateComponents.h"
    5959#include "DebugPageOverlays.h"
    60 #include "DocumentAnimationScheduler.h"
    6160#include "DocumentLoader.h"
    6261#include "DocumentMarkerController.h"
     
    19581957
    19591958        // Usually this is handled by post-layout.
    1960         if (!frameView.needsLayout()) {
     1959        if (!frameView.needsLayout())
    19611960            frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange();
    1962             if (m_needsForcedIntersectionObservationUpdate)
    1963                 page()->scheduleForcedIntersectionObservationUpdate(*this);
    1964         }
    19651961
    19661962        // As a result of the style recalculation, the currently hovered element might have been
     
    25592555    }
    25602556
    2561 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    2562     if (m_animationScheduler) {
    2563         m_animationScheduler->detachFromDocument();
    2564         m_animationScheduler = nullptr;
    2565     }
    2566 #endif
    2567 
    25682557#if ENABLE(CSS_PAINTING_API)
    25692558    for (auto& scope : m_paintWorkletGlobalScopes.values())
     
    62626251}
    62636252
     6253void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
     6254{
     6255    if (m_timeline)
     6256        m_timeline->updateAnimationsAndSendEvents(timestamp);
     6257}
     6258
     6259void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
     6260{
     6261    if (m_scriptedAnimationController)
     6262        m_scriptedAnimationController->serviceRequestAnimationFrameCallbacks(timestamp);
     6263}
     6264
    62646265void Document::windowScreenDidChange(PlatformDisplayID displayID)
    62656266{
    6266 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    6267     if (m_animationScheduler)
    6268         m_animationScheduler->windowScreenDidChange(displayID);
    6269 #endif
    6270 
    62716267    if (RenderView* view = renderView()) {
    62726268        if (view->usesCompositing())
     
    79307926        return;
    79317927
    7932     m_needsForcedIntersectionObservationUpdate = false;
    7933 
    79347928    for (const auto& observer : m_intersectionObservers) {
    79357929        bool needNotify = false;
     
    80068000    if (m_intersectionObserversWithPendingNotifications.size())
    80078001        m_intersectionObserversNotifyTimer.startOneShot(0_s);
    8008 }
    8009 
    8010 void Document::scheduleForcedIntersectionObservationUpdate()
    8011 {
    8012     ASSERT(!m_intersectionObservers.isEmpty());
    8013     if (m_needsForcedIntersectionObservationUpdate)
    8014         return;
    8015 
    8016     m_needsForcedIntersectionObservationUpdate = true;
    8017     if (auto* page = this->page())
    8018         page->scheduleForcedIntersectionObservationUpdate(*this);
    80198002}
    80208003
     
    84528435}
    84538436
    8454 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    8455 DocumentAnimationScheduler& Document::animationScheduler()
    8456 {
    8457     if (!m_animationScheduler)
    8458         m_animationScheduler = DocumentAnimationScheduler::create(*this, page() ? page()->chrome().displayID() : 0);
    8459 
    8460     return *m_animationScheduler;
    8461 }
    8462 #endif
    8463 
    84648437DocumentTimeline& Document::timeline()
    84658438{
  • trunk/Source/WebCore/dom/Document.h

    r242341 r242624  
    108108class DatabaseThread;
    109109class DeferredPromise;
    110 class DocumentAnimationScheduler;
    111110class DocumentFragment;
    112111class DocumentLoader;
     
    10461045    void suspendScriptedAnimationControllerCallbacks();
    10471046    void resumeScriptedAnimationControllerCallbacks();
    1048    
     1047
     1048    void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
     1049    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
     1050
    10491051    void windowScreenDidChange(PlatformDisplayID);
    10501052
     
    13991401    void removeIntersectionObserver(IntersectionObserver&);
    14001402    unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
    1401     void scheduleForcedIntersectionObservationUpdate();
    14021403    void updateIntersectionObservations();
    14031404#endif
     
    14721473    WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
    14731474
    1474 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    1475     DocumentAnimationScheduler& animationScheduler();
    1476 #endif
    1477 
    14781475    WEBCORE_EXPORT DocumentTimeline& timeline();
    14791476    DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
     
    20302027#endif
    20312028
    2032 #if ENABLE(INTERSECTION_OBSERVER)
    2033     bool m_needsForcedIntersectionObservationUpdate { false };
    2034 #endif
    2035 
    20362029#if ENABLE(MEDIA_STREAM)
    20372030    HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
     
    20532046    bool m_grantStorageAccessOverride { false };
    20542047
    2055 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    2056     RefPtr<DocumentAnimationScheduler> m_animationScheduler;
    2057 #endif
    20582048    RefPtr<DocumentTimeline> m_timeline;
    20592049    DocumentIdentifier m_identifier;
  • trunk/Source/WebCore/dom/ScriptedAnimationController.cpp

    r235560 r242624  
    3131#include "DOMWindow.h"
    3232#include "Document.h"
    33 #include "DocumentAnimationScheduler.h"
    3433#include "DocumentLoader.h"
    3534#include "Frame.h"
     
    190189}
    191190
    192 void ScriptedAnimationController::serviceScriptedAnimations(double timestamp)
     191void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
    193192{
    194193    if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
     
    198197
    199198    // We round this to the nearest microsecond so that we can return a time that matches what is returned by document.timeline.currentTime.
    200     double highResNowMs = std::round(1000 * timestamp);
    201     double legacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds());
     199    DOMHighResTimeStamp highResNowMs = std::round(1000 * timestamp);
     200    DOMHighResTimeStamp legacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds());
    202201
    203202    // First, generate a list of callbacks to consider.  Callbacks registered from this point
     
    211210
    212211    for (auto& callback : callbacks) {
    213         if (!callback->m_firedOrCancelled) {
    214             callback->m_firedOrCancelled = true;
    215             InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);
    216             if (callback->m_useLegacyTimeBase)
    217                 callback->handleEvent(legacyHighResNowMs);
    218             else
    219                 callback->handleEvent(highResNowMs);
    220             InspectorInstrumentation::didFireAnimationFrame(cookie);
    221         }
     212        if (callback->m_firedOrCancelled)
     213            continue;
     214        callback->m_firedOrCancelled = true;
     215        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);
     216        if (callback->m_useLegacyTimeBase)
     217            callback->handleEvent(legacyHighResNowMs);
     218        else
     219            callback->handleEvent(highResNowMs);
     220        InspectorInstrumentation::didFireAnimationFrame(cookie);
    222221    }
    223222
    224223    // Remove any callbacks we fired from the list of pending callbacks.
    225     for (size_t i = 0; i < m_callbacks.size();) {
    226         if (m_callbacks[i]->m_firedOrCancelled)
    227             m_callbacks.remove(i);
    228         else
    229             ++i;
    230     }
     224    m_callbacks.removeAllMatching([](auto& callback) {
     225        return callback->m_firedOrCancelled;
     226    });
    231227
    232228    if (m_callbacks.size())
     
    263259#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    264260    if (!m_isUsingTimer && !isThrottled()) {
    265         if (m_document->animationScheduler().scheduleScriptedAnimationResolution())
     261        if (auto* page = this->page()) {
     262            page->renderingUpdateScheduler().scheduleRenderingUpdate();
    266263            return;
     264        }
    267265
    268266        m_isUsingTimer = true;
     
    293291{
    294292    m_lastAnimationFrameTimestamp = m_document->domWindow()->nowTimestamp();
    295     serviceScriptedAnimations(m_lastAnimationFrameTimestamp);
    296 }
    297 
    298 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    299 void ScriptedAnimationController::documentAnimationSchedulerDidFire()
    300 {
    301     // We obtain the time from the animation scheduler so that we use the same timestamp as the DocumentTimeline.
    302     serviceScriptedAnimations(m_document->animationScheduler().lastTimestamp().seconds());
    303 }
    304 #endif
    305 
    306 }
     293    serviceRequestAnimationFrameCallbacks(m_lastAnimationFrameTimestamp);
     294}
     295
     296}
  • trunk/Source/WebCore/dom/ScriptedAnimationController.h

    r233140 r242624  
    5353    CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&);
    5454    void cancelCallback(CallbackId);
    55     void serviceScriptedAnimations(double timestamp);
     55    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
    5656
    5757    void suspend();
     
    6969    WEBCORE_EXPORT bool isThrottled() const;
    7070    WEBCORE_EXPORT Seconds interval() const;
    71 
    72 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    73     void documentAnimationSchedulerDidFire();
    74 #endif
    7571
    7672private:
  • trunk/Source/WebCore/page/FrameView.cpp

    r242082 r242624  
    19631963            renderView->updateVisibleViewportRect(visibleRect);
    19641964    });
    1965 
    1966 #if ENABLE(INTERSECTION_OBSERVER)
    1967     if (auto* document = frame().document()) {
    1968         if (auto* page = frame().page()) {
    1969             if (document->numberOfIntersectionObservers())
    1970                 page->addDocumentNeedingIntersectionObservationUpdate(*document);
    1971             if (!frame().isMainFrame()) {
    1972                 if (auto* mainDocument = frame().mainFrame().document()) {
    1973                     if (mainDocument->numberOfIntersectionObservers())
    1974                         page->addDocumentNeedingIntersectionObservationUpdate(*mainDocument);
    1975                 }
    1976             }
    1977         }
    1978     }
    1979 #endif
    19801965}
    19811966
  • trunk/Source/WebCore/page/IntersectionObserver.cpp

    r241130 r242624  
    158158    if (!hadObservationTargets)
    159159        document->addIntersectionObserver(*this);
    160     document->scheduleForcedIntersectionObservationUpdate();
    161160}
    162161
  • trunk/Source/WebCore/page/Page.cpp

    r242586 r242624  
    251251    , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider))
    252252    , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore))
    253 #if ENABLE(INTERSECTION_OBSERVER)
    254     , m_intersectionObservationUpdateTimer(*this, &Page::updateIntersectionObservations)
    255 #endif
    256253    , m_sessionID(PAL::SessionID::defaultSessionID())
    257254#if ENABLE(VIDEO)
     
    11121109}
    11131110
    1114 void Page::willDisplayPage()
    1115 {
    1116 #if ENABLE(INTERSECTION_OBSERVER)
    1117     updateIntersectionObservations();
    1118 #endif
    1119 }
    1120 
    11211111bool Page::isOnlyNonUtilityPage() const
    11221112{
     
    12601250}
    12611251
     1252void Page::layoutIfNeeded()
     1253{
     1254    if (FrameView* view = m_mainFrame->view())
     1255        view->updateLayoutAndStyleIfNeededRecursive();
     1256}
     1257
     1258void Page::renderingUpdate()
     1259{
     1260    // This function is not reentrant, e.g. a rAF callback may force repaint.
     1261    if (m_inRenderingUpdate) {
     1262        layoutIfNeeded();
     1263        return;
     1264    }
     1265
     1266    SetForScope<bool> change(m_inRenderingUpdate, true);
     1267
     1268    Vector<RefPtr<Document>> documents;
     1269
     1270    // The requestAnimationFrame callbacks may change the frame hierarchy of the page
     1271    forEachDocument([&documents] (Document& document) {
     1272        documents.append(&document);
     1273    });
     1274
     1275    for (auto& document : documents) {
     1276        DOMHighResTimeStamp timestamp = document->domWindow()->nowTimestamp();
     1277        document->updateAnimationsAndSendEvents(timestamp);
     1278        document->serviceRequestAnimationFrameCallbacks(timestamp);
     1279    }
     1280
     1281    layoutIfNeeded();
     1282
     1283    for (auto& document : documents) {
    12621284#if ENABLE(INTERSECTION_OBSERVER)
    1263 void Page::addDocumentNeedingIntersectionObservationUpdate(Document& document)
    1264 {
    1265     if (m_documentsNeedingIntersectionObservationUpdate.find(&document) == notFound)
    1266         m_documentsNeedingIntersectionObservationUpdate.append(makeWeakPtr(document));
    1267 }
    1268 
    1269 void Page::updateIntersectionObservations()
    1270 {
    1271     m_intersectionObservationUpdateTimer.stop();
    1272     for (const auto& document : m_documentsNeedingIntersectionObservationUpdate) {
    1273         if (document)
    1274             document->updateIntersectionObservations();
    1275     }
    1276     m_documentsNeedingIntersectionObservationUpdate.clear();
    1277 }
    1278 
    1279 void Page::scheduleForcedIntersectionObservationUpdate(Document& document)
    1280 {
    1281     addDocumentNeedingIntersectionObservationUpdate(document);
    1282     if (m_intersectionObservationUpdateTimer.isActive())
    1283         return;
    1284     m_intersectionObservationUpdateTimer.startOneShot(0_s);
    1285 }
    1286 #endif
     1285        document->updateIntersectionObservations();
     1286#endif
     1287    }
     1288}
    12871289
    12881290void Page::suspendScriptedAnimations()
     
    28242826}
    28252827
     2828RenderingUpdateScheduler& Page::renderingUpdateScheduler()
     2829{
     2830    if (!m_renderingUpdateScheduler)
     2831        m_renderingUpdateScheduler = RenderingUpdateScheduler::create(*this);
     2832    return *m_renderingUpdateScheduler;
     2833}
     2834
    28262835void Page::forEachDocument(const Function<void(Document&)>& functor)
    28272836{
  • trunk/Source/WebCore/page/Page.h

    r242340 r242624  
    3434#include "Region.h"
    3535#include "RegistrableDomain.h"
     36#include "RenderingUpdateScheduler.h"
    3637#include "ScrollTypes.h"
    3738#include "Supplementable.h"
     
    263264    PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); }
    264265
     266    RenderingUpdateScheduler& renderingUpdateScheduler();
     267
    265268    ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); }
    266269    void updateValidationBubbleStateIfNeeded();
     
    335338    void didFinishLoad(); // Called when the load has been committed in the main frame.
    336339
    337     WEBCORE_EXPORT void willDisplayPage();
    338 
    339340    // The view scale factor is multiplied into the page scale factor by all
    340341    // callers of setPageScaleFactor.
     
    464465    WEBCORE_EXPORT void removeActivityStateChangeObserver(ActivityStateChangeObserver&);
    465466
    466 #if ENABLE(INTERSECTION_OBSERVER)
    467     void addDocumentNeedingIntersectionObservationUpdate(Document&);
    468     void scheduleForcedIntersectionObservationUpdate(Document&);
    469     void updateIntersectionObservations();
    470 #endif
     467    WEBCORE_EXPORT void layoutIfNeeded();
     468    WEBCORE_EXPORT void renderingUpdate();
    471469
    472470    WEBCORE_EXPORT void suspendScriptedAnimations();
     
    862860    int m_headerHeight { 0 };
    863861    int m_footerHeight { 0 };
     862
     863    std::unique_ptr<RenderingUpdateScheduler> m_renderingUpdateScheduler;
    864864
    865865    HashSet<RenderObject*> m_relevantUnpaintedRenderObjects;
     
    902902
    903903    HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers;
    904 
    905 #if ENABLE(INTERSECTION_OBSERVER)
    906     Vector<WeakPtr<Document>> m_documentsNeedingIntersectionObservationUpdate;
    907 
    908     // FIXME: Schedule intersection observation updates in a way that fits into the HTML
    909     // EventLoop. See https://bugs.webkit.org/show_bug.cgi?id=160711.
    910     Timer m_intersectionObservationUpdateTimer;
    911 #endif
    912904
    913905#if ENABLE(RESOURCE_USAGE)
     
    971963    bool m_mediaPlaybackIsSuspended { false };
    972964    bool m_mediaBufferingIsSuspended { false };
     965    bool m_inRenderingUpdate { false };
    973966};
    974967
  • trunk/Source/WebCore/page/PageOverlayController.cpp

    r241978 r242624  
    319319void PageOverlayController::didChangeViewExposedRect()
    320320{
    321     m_page.chrome().client().scheduleCompositingLayerFlush();
     321    m_page.renderingUpdateScheduler().scheduleRenderingUpdate();
    322322}
    323323
     
    413413void PageOverlayController::notifyFlushRequired(const WebCore::GraphicsLayer*)
    414414{
    415     m_page.chrome().client().scheduleCompositingLayerFlush();
     415    m_page.renderingUpdateScheduler().scheduleRenderingUpdate();
    416416}
    417417
  • trunk/Source/WebCore/page/RenderingUpdateScheduler.h

    r242623 r242624  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    29 
    3028#include "DisplayRefreshMonitorClient.h"
    31 #include "PlatformScreen.h"
    32 #include <wtf/Ref.h>
    33 #include <wtf/RefCounted.h>
    34 #include <wtf/RefPtr.h>
    3529#include <wtf/Seconds.h>
    3630
    3731namespace WebCore {
    3832
    39 class Document;
     33class Page;
     34class Timer;
    4035
    41 class DocumentAnimationScheduler : public RefCounted<DocumentAnimationScheduler>
    42     , public DisplayRefreshMonitorClient {
     36class RenderingUpdateScheduler
     37#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     38    : public DisplayRefreshMonitorClient
     39#endif
     40{
     41    WTF_MAKE_FAST_ALLOCATED;
    4342public:
    44     static Ref<DocumentAnimationScheduler> create(Document&, PlatformDisplayID);
    45     ~DocumentAnimationScheduler();
     43    static std::unique_ptr<RenderingUpdateScheduler> create(Page& page)
     44    {
     45        return std::make_unique<RenderingUpdateScheduler>(page);
     46    }
    4647
    47     void detachFromDocument();
     48    RenderingUpdateScheduler(Page&);
     49    void scheduleRenderingUpdate();
     50
     51#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    4852    void windowScreenDidChange(PlatformDisplayID);
    49 
    50     bool scheduleWebAnimationsResolution();
    51     void unscheduleWebAnimationsResolution();
    52     bool scheduleScriptedAnimationResolution();
    53 
    54     Seconds lastTimestamp() { return m_lastTimestamp; }
    55     bool isFiring() const { return m_isFiring; }
     53#endif
    5654
    5755private:
    58     DocumentAnimationScheduler(Document&, PlatformDisplayID);
     56#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     57    RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const final;
     58    void displayRefreshFired() final;
     59#else
     60    void displayRefreshFired();
     61#endif
    5962
    60     RefPtr<Document> m_document;
    61     bool m_scheduledWebAnimationsResolution { false };
    62     bool m_scheduledScriptedAnimationResolution { false };
    63     bool m_isFiring { false };
    64     Seconds m_lastTimestamp { 0_s };
     63    bool isScheduled() const;
     64    void startTimer(Seconds);
     65    void clearScheduled();
    6566
    66     void displayRefreshFired() override;
    67     RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
     67    Page& m_page;
     68#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     69    bool m_scheduled { false };
     70#endif
     71    std::unique_ptr<Timer> m_refreshTimer;
    6872};
    6973
    70 } // namespace WebCore
    71 
    72 #endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     74}
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.h

    r242621 r242624  
    2828#if PLATFORM(IOS_FAMILY)
    2929
     30#include "Document.h"
     31#include "RenderStyleConstants.h"
    3032#include "WKContentObservation.h"
     33#include <wtf/HashSet.h>
     34#include <wtf/Seconds.h>
    3135
    3236namespace WebCore {
    3337
    3438class DOMTimer;
    35 class Document;
     39class Element;
    3640
    3741class ContentChangeObserver {
  • trunk/Source/WebCore/page/mac/ServicesOverlayController.mm

    r239535 r242624  
    122122        return;
    123123
    124     m_controller->page().chrome().client().scheduleCompositingLayerFlush();
     124    m_controller->page().renderingUpdateScheduler().scheduleRenderingUpdate();
    125125}
    126126
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r242359 r242624  
    432432{
    433433    m_hasPendingLayerFlush = false;
    434     page().chrome().client().scheduleCompositingLayerFlush();
     434    page().renderingUpdateScheduler().scheduleRenderingUpdate();
    435435}
    436436
  • trunk/Source/WebKit/ChangeLog

    r242621 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        Replace the calls to Page::layoutIfNeeded() and willDisplayPage() by
     9        a single call to Page::renderingUpdate(). This new function implements
     10        "Update the rendering" step of the HTML Event Loop specification
     11        <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.
     12
     13        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
     14        (WebKit::AcceleratedDrawingArea::updateBackingStoreState):
     15        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
     16        (WebKit::LayerTreeHost::layerFlushTimerFired):
     17        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     18        (WebKit::DrawingAreaImpl::display):
     19        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
     20        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
     21        * WebProcess/WebPage/WebPage.cpp:
     22        (WebKit::WebPage::layoutIfNeeded):
     23        (WebKit::WebPage::renderingUpdate):
     24        (WebKit::WebPage::willDisplayPage): Deleted.
     25        * WebProcess/WebPage/WebPage.h:
     26        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
     27        (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
     28
    1292019-03-07  Zalan Bujtas  <zalan@apple.com>
    230
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp

    r242364 r242624  
    382382        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
    383383        m_webPage.setSize(size);
    384         m_webPage.layoutIfNeeded();
     384        m_webPage.renderingUpdate();
    385385        m_webPage.flushPendingEditorStateUpdate();
    386386        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
    387         m_webPage.willDisplayPage();
    388387
    389388        if (m_layerTreeHost)
     
    704703    ASSERT(!m_webPage.size().isEmpty());
    705704
    706     m_webPage.layoutIfNeeded();
     705    m_webPage.renderingUpdate();
    707706    m_webPage.flushPendingEditorStateUpdate();
    708707
     
    712711        return;
    713712
    714     m_webPage.willDisplayPage();
    715713    updateInfo.viewSize = m_webPage.size();
    716714    updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp

    r242364 r242624  
    146146
    147147    m_coordinator.syncDisplayState();
     148    m_webPage.renderingUpdate();
    148149    m_webPage.flushPendingEditorStateUpdate();
    149     m_webPage.willDisplayPage();
    150150
    151151    if (!m_isValid || !m_coordinator.rootCompositingLayer())
  • trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm

    r241988 r242624  
    350350    backingStoreCollection.willFlushLayers();
    351351
    352     m_webPage.layoutIfNeeded();
    353     m_webPage.willDisplayPage();
     352    m_webPage.renderingUpdate();
    354353
    355354    FloatRect visibleRect(FloatPoint(), m_viewSize);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r242611 r242624  
    15551555}
    15561556
    1557 void WebPage::layoutIfNeeded()
    1558 {
    1559     if (m_mainFrame->coreFrame()->view())
    1560         m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
    1561 }
    1562 
    15631557WebPage* WebPage::fromCorePage(Page* page)
    15641558{
     
    35823576#endif
    35833577
    3584 void WebPage::willDisplayPage()
    3585 {
    3586     m_page->willDisplayPage();
     3578void WebPage::layoutIfNeeded()
     3579{
     3580    m_page->layoutIfNeeded();
     3581}
     3582   
     3583void WebPage::renderingUpdate()
     3584{
     3585    m_page->renderingUpdate();
    35873586}
    35883587
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r242587 r242624  
    302302#endif
    303303
    304     void willDisplayPage();
     304    void layoutIfNeeded();
     305    void renderingUpdate();
    305306
    306307    enum class LazyCreationPolicy { UseExistingOnly, CreateIfNeeded };
     
    335336    // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
    336337    void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
    337     void layoutIfNeeded();
    338338
    339339    // -- Called from WebCore clients.
  • trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

    r241988 r242624  
    6060#import <wtf/MachSendRight.h>
    6161#import <wtf/MainThread.h>
     62#import <wtf/SystemTracing.h>
    6263
    6364#if ENABLE(ASYNC_SCROLLING)
     
    460461        return;
    461462
     463    TraceScope traceScope(RenderingUpdateStart, RenderingUpdateEnd);
     464
    462465    @autoreleasepool {
    463466        scaleViewToFitDocumentIfNeeded();
    464467
    465         m_webPage.layoutIfNeeded();
     468        m_webPage.renderingUpdate();
    466469        m_webPage.flushPendingEditorStateUpdate();
    467         m_webPage.willDisplayPage();
    468470
    469471        updateIntrinsicContentSizeIfNeeded();
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r242621 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        * WebView/WebView.mm:
     9        (-[WebView _viewWillDrawInternal]):
     10        Call Page::renderingUpdate() which implements  "Update the rendering"
     11        step of the HTML Event Loop specification.
     12
    1132019-03-07  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r242621 r242624  
    16211621- (void)_viewWillDrawInternal
    16221622{
    1623     Frame* frame = [self _mainCoreFrame];
    1624     if (frame && frame->view())
    1625         frame->view()->updateLayoutAndStyleIfNeededRecursive();
     1623    if (_private->page)
     1624        _private->page->renderingUpdate();
    16261625}
    16271626
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r242592 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        * WebView.cpp:
     9        (WebView::updateBackingStore):
     10        (WebView::flushPendingGraphicsLayerChangesSoon):
     11        (WebView::flushPendingGraphicsLayerChanges):
     12        Call Page::renderingUpdate() which implements  "Update the rendering"
     13        step of the HTML Event Loop specification.
     14
    1152019-03-06  Ross Kirsling  <ross.kirsling@sony.com>
    216
  • trunk/Source/WebKitLegacy/win/WebView.cpp

    r242592 r242624  
    11741174    if (m_backingStoreBitmap && (m_backingStoreDirtyRegion || backingStoreCompletelyDirty)) {
    11751175        // Do a layout first so that everything we render to the backing store is always current.
    1176         if (Frame* coreFrame = core(m_mainFrame))
    1177             if (FrameView* view = coreFrame->view())
    1178                 view->updateLayoutAndStyleIfNeededRecursive();
     1176        m_page->renderingUpdate();
    11791177
    11801178        Vector<IntRect> paintRects;
     
    71607158{
    71617159#if USE(CA)
    7162     if (!m_layerTreeHost)
     7160    if (!m_layerTreeHost) {
     7161        m_page->renderingUpdate();
    71637162        return;
     7163    }
    71647164    m_layerTreeHost->flushPendingGraphicsLayerChangesSoon();
    71657165#elif USE(TEXTURE_MAPPER_GL)
     
    73897389        return;
    73907390
    7391     view->updateLayoutAndStyleIfNeededRecursive();
     7391    m_page->renderingUpdate();
    73927392
    73937393    // Updating layout might have taken us out of compositing mode.
  • trunk/Tools/ChangeLog

    r242621 r242624  
     12019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        requestAnimationFrame should execute before the next frame
     4        https://bugs.webkit.org/show_bug.cgi?id=177484
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add trace points for the page RenderingUpdate.
     9
     10        * Tracing/SystemTracePoints.plist:
     11
    1122019-03-07  Zalan Bujtas  <zalan@apple.com>
    213
  • trunk/Tools/Tracing/SystemTracePoints.plist

    r242294 r242624  
    219219             <dict>
    220220                 <key>Name</key>
     221                 <string>Schedule rendering update</string>
     222                 <key>Type</key>
     223                 <string>Impulse</string>
     224                 <key>Component</key>
     225                 <string>47</string>
     226                 <key>Code</key>
     227                 <string>5028</string>
     228             </dict>
     229             <dict>
     230                 <key>Name</key>
     231                 <string>Trigger rendering update</string>
     232                 <key>Type</key>
     233                 <string>Impulse</string>
     234                 <key>Component</key>
     235                 <string>47</string>
     236                 <key>Code</key>
     237                 <string>5029</string>
     238             </dict>
     239             <dict>
     240                 <key>Name</key>
     241                 <string>Rendering update</string>
     242                 <key>Type</key>
     243                 <string>Interval</string>
     244                 <key>Component</key>
     245                 <string>47</string>
     246                 <key>CodeBegin</key>
     247                 <string>5030</string>
     248                 <key>CodeEnd</key>
     249                 <string>5031</string>
     250             </dict>
     251             <dict>
     252                 <key>Name</key>
    221253                 <string>Paint WebHTMLView</string>
    222254                 <key>Type</key>
Note: See TracChangeset for help on using the changeset viewer.