Changeset 260736 in webkit


Ignore:
Timestamp:
Apr 26, 2020 6:02:58 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Rendering update steps should use Seconds for the timestamps
https://bugs.webkit.org/show_bug.cgi?id=210990

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2020-04-26
Reviewed by Daniel Bates.

Source/WebCore:

Make DOMWindow::nowTimestamp() return ReducedResolutionSeconds and change
the callers accordingly. ReducedResolutionSeconds is a new type but it's
just an alias of the type Seconds. It indicates that the returned value
is a web-safe seconds.

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • animation/DocumentTimeline.cpp:

(WebCore::DocumentTimeline::suspendAnimations):
(WebCore::DocumentTimeline::liveCurrentTime const):
(WebCore::DocumentTimeline::cacheCurrentTime):
(WebCore::DocumentTimeline::documentWillUpdateAnimationsAndSendEvents):

  • animation/DocumentTimeline.h:
  • animation/DocumentTimelinesController.cpp:

(WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):

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

(WebCore::Document::serviceRequestAnimationFrameCallbacks):
(WebCore::Document::updateIntersectionObservations):

  • dom/Document.h:
  • dom/ScriptedAnimationController.cpp:

(WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
(WebCore::ScriptedAnimationController::scheduleAnimation):

  • dom/ScriptedAnimationController.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::getVideoPlaybackQuality):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::nowTimestamp const):

  • page/DOMWindow.h:
  • page/IntersectionObserver.cpp:

(WebCore::IntersectionObserver::nowTimestamp const):
(WebCore::IntersectionObserver::createTimestamp const): Deleted.

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

(WebCore::Page::updateRendering):

  • page/Performance.cpp:

(WebCore::Performance::now const):
(WebCore::Performance::nowInReducedResolutionSeconds const):

  • page/Performance.h:
  • page/ReducedResolutionSeconds.h: Added.

Source/WebKit:

  • WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:

(WebKit::CompositingCoordinator::timestamp const):

Location:
trunk/Source
Files:
1 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r260732 r260736  
     12020-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Rendering update steps should use Seconds for the timestamps
     4        https://bugs.webkit.org/show_bug.cgi?id=210990
     5
     6        Reviewed by Daniel Bates.
     7
     8        Make DOMWindow::nowTimestamp() return ReducedResolutionSeconds and change
     9        the callers accordingly. ReducedResolutionSeconds is a new type but it's
     10        just an alias of the type Seconds. It indicates that the returned value
     11        is a web-safe seconds.
     12
     13        * Headers.cmake:
     14        * WebCore.xcodeproj/project.pbxproj:
     15        * animation/DocumentTimeline.cpp:
     16        (WebCore::DocumentTimeline::suspendAnimations):
     17        (WebCore::DocumentTimeline::liveCurrentTime const):
     18        (WebCore::DocumentTimeline::cacheCurrentTime):
     19        (WebCore::DocumentTimeline::documentWillUpdateAnimationsAndSendEvents):
     20        * animation/DocumentTimeline.h:
     21        * animation/DocumentTimelinesController.cpp:
     22        (WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):
     23        * animation/DocumentTimelinesController.h:
     24        * dom/Document.cpp:
     25        (WebCore::Document::serviceRequestAnimationFrameCallbacks):
     26        (WebCore::Document::updateIntersectionObservations):
     27        * dom/Document.h:
     28        * dom/ScriptedAnimationController.cpp:
     29        (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
     30        (WebCore::ScriptedAnimationController::scheduleAnimation):
     31        * dom/ScriptedAnimationController.h:
     32        * html/HTMLMediaElement.cpp:
     33        (WebCore::HTMLMediaElement::getVideoPlaybackQuality):
     34        * page/DOMWindow.cpp:
     35        (WebCore::DOMWindow::nowTimestamp const):
     36        * page/DOMWindow.h:
     37        * page/IntersectionObserver.cpp:
     38        (WebCore::IntersectionObserver::nowTimestamp const):
     39        (WebCore::IntersectionObserver::createTimestamp const): Deleted.
     40        * page/IntersectionObserver.h:
     41        * page/Page.cpp:
     42        (WebCore::Page::updateRendering):
     43        * page/Performance.cpp:
     44        (WebCore::Performance::now const):
     45        (WebCore::Performance::nowInReducedResolutionSeconds const):
     46        * page/Performance.h:
     47        * page/ReducedResolutionSeconds.h: Added.
     48
    1492020-04-26  Alexey Shvayka  <shvaikalesh@gmail.com>
    250
  • trunk/Source/WebCore/Headers.cmake

    r260724 r260736  
    841841    page/ProcessWarming.h
    842842    page/Quirks.h
     843    page/ReducedResolutionSeconds.h
    843844    page/RemoteDOMWindow.h
    844845    page/RemoteFrame.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r260729 r260736  
    17501750                556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17511751                5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1752                5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */ = {isa = PBXBuildFile; fileRef = 558476582453ABC2009F550C /* ReducedResolutionSeconds.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17521753                55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17531754                55AD093E2408963500DE4D2F /* DisplayListImageBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    87398740                5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; };
    87408741                5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
     8742                558476582453ABC2009F550C /* ReducedResolutionSeconds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReducedResolutionSeconds.h; sourceTree = "<group>"; };
    87418743                5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
    87428744                55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
     
    2107821080                                CD9A87F9215D6CF3006F17B5 /* Quirks.cpp */,
    2107921081                                CD9A87FB215D6CF3006F17B5 /* Quirks.h */,
     21082                                558476582453ABC2009F550C /* ReducedResolutionSeconds.h */,
    2108021083                                46B9518D207D632A00A7D2DD /* RemoteDOMWindow.cpp */,
    2108121084                                46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */,
     
    3242932432                                FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
    3243032433                                5CEEE4361F5F8F210014A5F5 /* RectEdges.h in Headers */,
     32434                                5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */,
    3243132435                                9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
    3243232436                                BCAB418213E356E800D8AAF3 /* Region.h in Headers */,
  • trunk/Source/WebCore/animation/DocumentTimeline.cpp

    r260525 r260736  
    233233
    234234    if (!m_cachedCurrentTime)
    235         m_cachedCurrentTime = Seconds(liveCurrentTime());
     235        m_cachedCurrentTime = liveCurrentTime();
    236236
    237237    for (const auto& animation : m_animations)
     
    275275}
    276276
    277 DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const
     277ReducedResolutionSeconds DocumentTimeline::liveCurrentTime() const
    278278{
    279279    return m_document->domWindow()->nowTimestamp();
     
    298298}
    299299
    300 void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime)
     300void DocumentTimeline::cacheCurrentTime(ReducedResolutionSeconds newCurrentTime)
    301301{
    302302    ASSERT(m_document);
    303303
    304     m_cachedCurrentTime = Seconds(newCurrentTime);
     304    m_cachedCurrentTime = newCurrentTime;
    305305    // We want to be sure to keep this time cached until we've both finished running JS and finished updating
    306306    // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
     
    362362}
    363363
    364 DocumentTimeline::ShouldUpdateAnimationsAndSendEvents DocumentTimeline::documentWillUpdateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
     364DocumentTimeline::ShouldUpdateAnimationsAndSendEvents DocumentTimeline::documentWillUpdateAnimationsAndSendEvents(ReducedResolutionSeconds timestamp)
    365365{
    366366    // We need to freeze the current time even if no animation is running.
  • trunk/Source/WebCore/animation/DocumentTimeline.h

    r260525 r260736  
    2929#include "DocumentTimelineOptions.h"
    3030#include "GenericTaskQueue.h"
     31#include "ReducedResolutionSeconds.h"
    3132#include "Timer.h"
    3233#include <wtf/Markable.h>
     
    7576   
    7677    enum class ShouldUpdateAnimationsAndSendEvents : uint8_t { Yes, No };
    77     ShouldUpdateAnimationsAndSendEvents documentWillUpdateAnimationsAndSendEvents(DOMHighResTimeStamp);
     78    ShouldUpdateAnimationsAndSendEvents documentWillUpdateAnimationsAndSendEvents(ReducedResolutionSeconds);
    7879    void removeReplacedAnimations();
    7980    AnimationEvents prepareForPendingAnimationEventsDispatch();
     
    9394
    9495    DocumentTimelinesController* controller() const;
    95     DOMHighResTimeStamp liveCurrentTime() const;
     96    ReducedResolutionSeconds liveCurrentTime() const;
    9697    void applyPendingAcceleratedAnimations();
    97     void cacheCurrentTime(DOMHighResTimeStamp);
     98    void cacheCurrentTime(ReducedResolutionSeconds);
    9899    void maybeClearCachedCurrentTime();
    99100    void scheduleInvalidationTaskIfNeeded();
  • trunk/Source/WebCore/animation/DocumentTimelinesController.cpp

    r260525 r260736  
    6262}
    6363
    64 void DocumentTimelinesController::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
     64void DocumentTimelinesController::updateAnimationsAndSendEvents(ReducedResolutionSeconds timestamp)
    6565{
    6666    ASSERT(!m_timelines.hasNullReferences());
  • trunk/Source/WebCore/animation/DocumentTimelinesController.h

    r260525 r260736  
    2626#pragma once
    2727
    28 #include "DOMHighResTimeStamp.h"
     28#include "ReducedResolutionSeconds.h"
    2929#include <wtf/WeakHashSet.h>
    3030
     
    4545    void removeTimeline(DocumentTimeline&);
    4646    void detachFromDocument();
    47     void updateAnimationsAndSendEvents(DOMHighResTimeStamp);
     47    void updateAnimationsAndSendEvents(ReducedResolutionSeconds);
    4848
    4949private:
  • trunk/Source/WebCore/dom/Document.cpp

    r260709 r260736  
    63726372}
    63736373
    6374 void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
     6374void Document::serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds timestamp)
    63756375{
    63766376    if (m_scriptedAnimationController)
     
    76237623    for (const auto& observer : m_intersectionObservers) {
    76247624        bool needNotify = false;
    7625         DOMHighResTimeStamp timestamp;
    7626         if (!observer->createTimestamp(timestamp))
     7625        auto timestamp = observer->nowTimestamp();
     7626        if (!timestamp)
    76277627            continue;
    76287628        for (Element* target : observer->observationTargets()) {
     
    76777677
    76787678                observer->appendQueuedEntry(IntersectionObserverEntry::create({
    7679                     timestamp,
     7679                    timestamp->milliseconds(),
    76807680                    reportedRootBounds,
    76817681                    { targetBoundingClientRect.x(), targetBoundingClientRect.y(), targetBoundingClientRect.width(), targetBoundingClientRect.height() },
  • trunk/Source/WebCore/dom/Document.h

    r260504 r260736  
    10811081    void resumeScriptedAnimationControllerCallbacks();
    10821082
    1083     void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp);
     1083    void serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds);
    10841084
    10851085    void windowScreenDidChange(PlatformDisplayID);
  • trunk/Source/WebCore/dom/ScriptedAnimationController.cpp

    r260140 r260736  
    194194}
    195195
    196 void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
     196void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds timestamp)
    197197{
    198198    if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
     
    201201    TraceScope tracingScope(RAFCallbackStart, RAFCallbackEnd);
    202202
    203     auto highResNowMs = std::round(1000 * timestamp);
     203    auto highResNowMs = timestamp.milliseconds();
    204204    if (m_document && m_document->quirks().needsMillisecondResolutionForHighResTimeStamp())
    205205        highResNowMs += 0.1;
     
    274274
    275275    Seconds animationInterval = interval();
    276     Seconds scheduleDelay = std::max(animationInterval - Seconds(m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0_s);
     276    Seconds scheduleDelay = std::max(animationInterval - (m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0_s);
    277277
    278278    if (isThrottled()) {
  • trunk/Source/WebCore/dom/ScriptedAnimationController.h

    r256512 r260736  
    5454    CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&);
    5555    void cancelCallback(CallbackId);
    56     void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
     56    void serviceRequestAnimationFrameCallbacks(ReducedResolutionSeconds);
    5757
    5858    void suspend();
     
    8787
    8888    Timer m_animationTimer;
    89     double m_lastAnimationFrameTimestamp { 0 };
     89    ReducedResolutionSeconds m_lastAnimationFrameTimestamp { 0 };
    9090
    9191#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r260724 r260736  
    71117111{
    71127112    RefPtr<DOMWindow> domWindow = document().domWindow();
    7113     double timestamp = domWindow ? 1000 * domWindow->nowTimestamp() : 0;
     7113    double timestamp = domWindow ? domWindow->nowTimestamp().milliseconds() : 0;
    71147114
    71157115    auto metrics = m_player ? m_player->videoPlaybackQualityMetrics() : WTF::nullopt;
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r260724 r260736  
    735735}
    736736
    737 double DOMWindow::nowTimestamp() const
    738 {
    739     return performance().now() / 1000.;
     737ReducedResolutionSeconds DOMWindow::nowTimestamp() const
     738{
     739    return performance().nowInReducedResolutionSeconds();
    740740}
    741741
  • trunk/Source/WebCore/page/DOMWindow.h

    r260653 r260736  
    3535#include "ImageBitmap.h"
    3636#include "PostMessageOptions.h"
     37#include "ReducedResolutionSeconds.h"
    3738#include "ScrollToOptions.h"
    3839#include "ScrollTypes.h"
     
    350351
    351352    Performance& performance() const;
    352     WEBCORE_EXPORT double nowTimestamp() const;
     353    WEBCORE_EXPORT ReducedResolutionSeconds nowTimestamp() const;
    353354
    354355#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebCore/page/IntersectionObserver.cpp

    r259252 r260736  
    245245}
    246246
    247 bool IntersectionObserver::createTimestamp(DOMHighResTimeStamp& timestamp) const
     247Optional<ReducedResolutionSeconds> IntersectionObserver::nowTimestamp() const
    248248{
    249249    if (!m_callback)
    250         return false;
     250        return WTF::nullopt;
    251251
    252252    auto* context = m_callback->scriptExecutionContext();
    253253    if (!context)
    254         return false;
     254        return WTF::nullopt;
     255
    255256    ASSERT(context->isDocument());
    256257    auto& document = downcast<Document>(*context);
    257     if (auto* window = document.domWindow()) {
    258         timestamp =  window->performance().now();
    259         return true;
    260     }
    261     return false;
     258    if (auto* window = document.domWindow())
     259        return window->nowTimestamp();
     260   
     261    return WTF::nullopt;
    262262}
    263263
  • trunk/Source/WebCore/page/IntersectionObserver.h

    r259252 r260736  
    9595    void rootDestroyed();
    9696
    97     bool createTimestamp(DOMHighResTimeStamp&) const;
     97    Optional<ReducedResolutionSeconds> nowTimestamp() const;
    9898
    9999    void appendQueuedEntry(Ref<IntersectionObserverEntry>&&);
  • trunk/Source/WebCore/page/Page.cpp

    r260725 r260736  
    13591359        if (!document.domWindow())
    13601360            return;
    1361         DOMHighResTimeStamp timestamp = document.domWindow()->nowTimestamp();
     1361        auto timestamp = document.domWindow()->nowTimestamp();
    13621362        if (auto* timelinesController = document.timelinesController())
    13631363            timelinesController->updateAnimationsAndSendEvents(timestamp);
  • trunk/Source/WebCore/page/Performance.cpp

    r248846 r260736  
    7575DOMHighResTimeStamp Performance::now() const
    7676{
     77    return nowInReducedResolutionSeconds().milliseconds();
     78}
     79
     80ReducedResolutionSeconds Performance::nowInReducedResolutionSeconds() const
     81{
    7782    Seconds now = MonotonicTime::now() - m_timeOrigin;
    78     return reduceTimeResolution(now).milliseconds();
     83    return reduceTimeResolution(now);
    7984}
    8085
  • trunk/Source/WebCore/page/Performance.h

    r243887 r260736  
    3838#include "ExceptionOr.h"
    3939#include "GenericTaskQueue.h"
     40#include "ReducedResolutionSeconds.h"
    4041#include <wtf/ListHashSet.h>
    4142
     
    5960
    6061    DOMHighResTimeStamp now() const;
     62    ReducedResolutionSeconds nowInReducedResolutionSeconds() const;
    6163
    6264    PerformanceNavigation* navigation();
  • trunk/Source/WebKit/ChangeLog

    r260729 r260736  
     12020-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Rendering update steps should use Seconds for the timestamps
     4        https://bugs.webkit.org/show_bug.cgi?id=210990
     5
     6        Reviewed by Daniel Bates.
     7
     8        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
     9        (WebKit::CompositingCoordinator::timestamp const):
     10
    1112020-04-26  Peng Liu  <peng.liu6@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp

    r259284 r260736  
    181181    if (!document)
    182182        return 0;
    183     return document->domWindow() ? document->domWindow()->nowTimestamp() : document->monotonicTimestamp();
     183    return document->domWindow() ? document->domWindow()->nowTimestamp().seconds() : document->monotonicTimestamp();
    184184}
    185185
Note: See TracChangeset for help on using the changeset viewer.