Title: [286877] trunk/Source
Revision
286877
Author
grao...@webkit.org
Date
2021-12-10 14:17:27 -0800 (Fri, 10 Dec 2021)

Log Message

Expose the maximum device frame rate to the Web Animations model
https://bugs.webkit.org/show_bug.cgi?id=234161
rdar://85983792

Reviewed by Simon Fraser.

Source/WebCore:

Expose a new property on DocumentTimeline, governed by an off-by-default runtime flag,
that exposes the maximum frame rate supported by the device. This will allow authors
to use this information to make informed decision on appropriate frame rates to set
on animations.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::maximumFrameRate const):
* animation/DocumentTimeline.h:
* animation/DocumentTimeline.idl:

Source/WebCore/PAL:

Add a newly-used CADisplayLink SPI.

* pal/spi/cocoa/QuartzCoreSPI.h:

Source/WebKit:

The display's nominal frame rate was only provided to the Page on macOS. We also
expose it on iOS such that the new DocumentTimeline property also works on iOS.

* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(-[WKOneShotDisplayLinkHandler initWithDrawingAreaProxy:]):
* UIProcess/WebPageProxy.h:

Source/WTF:

Add a new experimental feature controlling the availability of per-animation frame rate.

* Scripts/Preferences/WebPreferencesExperimental.yaml:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (286876 => 286877)


--- trunk/Source/WTF/ChangeLog	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WTF/ChangeLog	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1,3 +1,15 @@
+2021-12-10  Antoine Quint  <grao...@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Add a new experimental feature controlling the availability of per-animation frame rate.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
 2021-12-10  Sam Sneddon  <gsnedd...@apple.com>
 
         Enable the 'resolution' media query by default

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (286876 => 286877)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1496,6 +1496,19 @@
     WebCore:
       default: false
 
+WebAnimationsCustomFrameRateEnabled:
+  type: bool
+  humanReadableName: "Web Animations custom frame rate"
+  humanReadableDescription: "Support for specifying a custom frame rate for Web Animations"
+  defaultValue:
+    WebKitLegacy:
+      default: false
+    WebKit:
+      "ENABLE(EXPERIMENTAL_FEATURES)" : true
+      default: false
+    WebCore:
+      default: false
+
 # FIXME: This is enabled when ENABLE(EXPERIMENTAL_FEATURES) is true in WebKit2. Perhaps we should consider using that for WebKitLegacy as well.
 WebAnimationsMutableTimelinesEnabled:
   type: bool

Modified: trunk/Source/WebCore/ChangeLog (286876 => 286877)


--- trunk/Source/WebCore/ChangeLog	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/ChangeLog	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1,3 +1,21 @@
+2021-12-10  Antoine Quint  <grao...@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Expose a new property on DocumentTimeline, governed by an off-by-default runtime flag,
+        that exposes the maximum frame rate supported by the device. This will allow authors
+        to use this information to make informed decision on appropriate frame rates to set
+        on animations.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::maximumFrameRate const):
+        * animation/DocumentTimeline.h:
+        * animation/DocumentTimeline.idl:
+
 2021-12-10  Alexey Shvayka  <ashva...@apple.com>
 
         Extend the scope where the Window's current event is set

Modified: trunk/Source/WebCore/PAL/ChangeLog (286876 => 286877)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1,3 +1,15 @@
+2021-12-10  Antoine Quint  <grao...@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        Add a newly-used CADisplayLink SPI.
+
+        * pal/spi/cocoa/QuartzCoreSPI.h:
+
 2021-12-09  Robert Jenner  <jen...@apple.com>
 
         Unreviewed, reverting r286754.

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h (286876 => 286877)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h	2021-12-10 22:17:27 UTC (rev 286877)
@@ -48,6 +48,10 @@
 #import <QuartzCore/CARenderCG.h>
 #endif
 
+#if PLATFORM(IOS_FAMILY)
+#import <QuartzCore/CADisplayLinkPrivate.h>
+#endif
+
 #endif // __OBJC__
 
 #else
@@ -55,6 +59,12 @@
 #ifdef __OBJC__
 typedef struct _CARenderContext CARenderContext;
 
+#if PLATFORM(IOS_FAMILY)
+@interface CADisplayLink ()
+@property (readonly, nonatomic) CFTimeInterval maximumRefreshRate;
+@end
+#endif
+
 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)
 @class CAFenceHandle;
 #endif

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (286876 => 286877)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2021-12-10 22:17:27 UTC (rev 286877)
@@ -530,4 +530,11 @@
     return animation;
 }
 
+std::optional<FramesPerSecond> DocumentTimeline::maximumFrameRate() const
+{
+    if (!m_document || !m_document->page())
+        return std::nullopt;
+    return m_document->page()->displayNominalFramesPerSecond();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (286876 => 286877)


--- trunk/Source/WebCore/animation/DocumentTimeline.h	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h	2021-12-10 22:17:27 UTC (rev 286877)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "AnimationFrameRate.h"
 #include "AnimationTimeline.h"
 #include "DocumentTimelineOptions.h"
 #include "Timer.h"
@@ -85,6 +86,8 @@
     WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForElement(Element&) const;    
     WEBCORE_EXPORT unsigned numberOfAnimationTimelineInvalidationsForTesting() const;
 
+    std::optional<FramesPerSecond> maximumFrameRate() const;
+
 private:
     DocumentTimeline(Document&, Seconds);
 

Modified: trunk/Source/WebCore/animation/DocumentTimeline.idl (286876 => 286877)


--- trunk/Source/WebCore/animation/DocumentTimeline.idl	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebCore/animation/DocumentTimeline.idl	2021-12-10 22:17:27 UTC (rev 286877)
@@ -23,9 +23,12 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+typedef unsigned long FramesPerSecond;
+
 [
     Exposed=Window
 ] interface DocumentTimeline : AnimationTimeline {
     [CallWith=Document] constructor(optional DocumentTimelineOptions options);
     [EnabledBySetting=WebAnimationsCustomEffectsEnabled] WebAnimation animate(CustomEffectCallback callback, optional (unrestricted double or CustomAnimationOptions) options);
+    [EnabledBySetting=WebAnimationsCustomFrameRateEnabled] readonly attribute FramesPerSecond? maximumFrameRate;
 };

Modified: trunk/Source/WebKit/ChangeLog (286876 => 286877)


--- trunk/Source/WebKit/ChangeLog	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/ChangeLog	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1,3 +1,18 @@
+2021-12-10  Antoine Quint  <grao...@webkit.org>
+
+        Expose the maximum device frame rate to the Web Animations model
+        https://bugs.webkit.org/show_bug.cgi?id=234161
+        rdar://85983792
+
+        Reviewed by Simon Fraser.
+
+        The display's nominal frame rate was only provided to the Page on macOS. We also
+        expose it on iOS such that the new DocumentTimeline property also works on iOS.
+
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (-[WKOneShotDisplayLinkHandler initWithDrawingAreaProxy:]):
+        * UIProcess/WebPageProxy.h:
+
 2021-12-10  Devin Rousso  <drou...@apple.com>
 
         Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (286876 => 286877)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm	2021-12-10 22:17:27 UTC (rev 286877)
@@ -34,9 +34,11 @@
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import <QuartzCore/QuartzCore.h>
+#import <WebCore/AnimationFrameRate.h>
 #import <WebCore/GraphicsContextCG.h>
 #import <WebCore/IOSurfacePool.h>
 #import <WebCore/WebActionDisablingCALayerDelegate.h>
+#import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/MachSendRight.h>
 #import <wtf/SystemTracing.h>
 
@@ -67,6 +69,17 @@
         [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
         _displayLink.paused = YES;
         _displayLink.preferredFramesPerSecond = 60;
+
+        if (drawingAreaProxy) {
+            auto minimumRefreshInterval = _displayLink.maximumRefreshRate;
+            if (minimumRefreshInterval > 0) {
+                auto& page = drawingAreaProxy->page();
+                if (auto displayId = page.displayId()) {
+                    WebCore::FramesPerSecond frameRate = std::round(1.0 / minimumRefreshInterval);
+                    page.windowScreenDidChange(*displayId, frameRate);
+                }
+            }
+        }
     }
     return self;
 }

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (286876 => 286877)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-10 22:15:52 UTC (rev 286876)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-10 22:17:27 UTC (rev 286877)
@@ -1105,6 +1105,7 @@
     void setIntrinsicDeviceScaleFactor(float);
     void setCustomDeviceScaleFactor(float);
     void windowScreenDidChange(WebCore::PlatformDisplayID, std::optional<unsigned> nominalFramesPerSecond);
+    std::optional<WebCore::PlatformDisplayID> displayId() const { return m_displayID; }
     void accessibilitySettingsDidChange();
 
     void setUseFixedLayout(bool);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to