Add support for reporting "display composited video frames" through the VideoPlayback...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2018 01:11:22 +0000 (01:11 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2018 01:11:22 +0000 (01:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190266

Reviewed by Eric Carlson.

Source/WebCore:

Test: TestWebKitAPI.VideoQualityDisplayCompositing

Modify VideoPlaybackQuality to take a VideoPlaybackQualityMetrics object in its
constructor (rather than individual fields). Add a new setting to control visibility
of the displayCompositedVideoFrames attribute on VideoPlaybackQuality. Add support
for VideoPlaybackQualityMetrics to MediaPlayerPrivateAVFoundationObjC.

* Modules/mediasource/VideoPlaybackQuality.cpp:
(WebCore::VideoPlaybackQuality::create):
(WebCore::VideoPlaybackQuality::VideoPlaybackQuality):
* Modules/mediasource/VideoPlaybackQuality.h:
(WebCore::VideoPlaybackQuality::displayCompositedVideoFrames const):
* Modules/mediasource/VideoPlaybackQuality.idl:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getVideoPlaybackQuality):
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:
* page/Settings.yaml:
* platform/graphics/MediaPlayer.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::videoPlaybackQualityMetrics):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::videoPlaybackQualityMetrics):
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::videoPlaybackQualityMetrics):

Source/WebCore/PAL:

* pal/spi/mac/AVFoundationSPI.h:

Source/WebKit:

Add a new preference to control the visibility of displayCompositedVideoFrames in the VideoPlaybackQualityObject.

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setVideoQualityIncludesDisplayCompositingEnabled:]):
(-[WKPreferences _videoQualityIncludesDisplayCompositingEnabled]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm: Added.
(TestWebKitAPI::TEST):

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

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.cpp
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.h
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.idl
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/mac/AVFoundationSPI.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm [new file with mode: 0644]

index 31d5ee4..36eab33 100644 (file)
@@ -1,3 +1,37 @@
+2018-10-04  Jer Noble  <jer.noble@apple.com>
+
+        Add support for reporting "display composited video frames" through the VideoPlaybackQuality object.
+        https://bugs.webkit.org/show_bug.cgi?id=190266
+
+        Reviewed by Eric Carlson.
+
+        Test: TestWebKitAPI.VideoQualityDisplayCompositing
+
+        Modify VideoPlaybackQuality to take a VideoPlaybackQualityMetrics object in its
+        constructor (rather than individual fields). Add a new setting to control visibility
+        of the displayCompositedVideoFrames attribute on VideoPlaybackQuality. Add support
+        for VideoPlaybackQualityMetrics to MediaPlayerPrivateAVFoundationObjC.
+
+        * Modules/mediasource/VideoPlaybackQuality.cpp:
+        (WebCore::VideoPlaybackQuality::create):
+        (WebCore::VideoPlaybackQuality::VideoPlaybackQuality):
+        * Modules/mediasource/VideoPlaybackQuality.h:
+        (WebCore::VideoPlaybackQuality::displayCompositedVideoFrames const):
+        * Modules/mediasource/VideoPlaybackQuality.idl:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::getVideoPlaybackQuality):
+        * html/HTMLMediaElement.h:
+        * html/HTMLMediaElement.idl:
+        * page/Settings.yaml:
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::videoPlaybackQualityMetrics):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::videoPlaybackQualityMetrics):
+        * platform/mock/mediasource/MockMediaSourcePrivate.cpp:
+        (WebCore::MockMediaSourcePrivate::videoPlaybackQualityMetrics):
+
 2018-10-04  Chris Dumez  <cdumez@apple.com>
 
         A Document / Window should lose its browsing context as soon as its iframe is removed from the document
index ac7498c..398e788 100644 (file)
 #include "config.h"
 #include "VideoPlaybackQuality.h"
 
+#include "MediaPlayer.h"
+
 namespace WebCore {
 
-Ref<VideoPlaybackQuality> VideoPlaybackQuality::create(double creationTime, unsigned totalVideoFrames, unsigned droppedVideoFrames, unsigned corruptedVideoFrames, double totalFrameDelay)
+Ref<VideoPlaybackQuality> VideoPlaybackQuality::create(double creationTime, const VideoPlaybackQualityMetrics& metrics)
 {
-    return adoptRef(*new VideoPlaybackQuality(creationTime, totalVideoFrames, droppedVideoFrames, corruptedVideoFrames, totalFrameDelay));
+    return adoptRef(*new VideoPlaybackQuality(creationTime, metrics));
 }
 
-VideoPlaybackQuality::VideoPlaybackQuality(double creationTime, unsigned totalVideoFrames, unsigned droppedVideoFrames, unsigned corruptedVideoFrames, double totalFrameDelay)
+VideoPlaybackQuality::VideoPlaybackQuality(double creationTime, const VideoPlaybackQualityMetrics& metrics)
     : m_creationTime(creationTime)
-    , m_totalVideoFrames(totalVideoFrames)
-    , m_droppedVideoFrames(droppedVideoFrames)
-    , m_corruptedVideoFrames(corruptedVideoFrames)
-    , m_totalFrameDelay(totalFrameDelay)
+    , m_totalVideoFrames(metrics.totalVideoFrames)
+    , m_droppedVideoFrames(metrics.droppedVideoFrames)
+    , m_corruptedVideoFrames(metrics.corruptedVideoFrames)
+    , m_displayCompositedVideoFrames(metrics.displayCompositedVideoFrames)
+    , m_totalFrameDelay(metrics.totalFrameDelay)
 {
 }
 
index bb9516d..138ea10 100644 (file)
 
 namespace WebCore {
 
+struct VideoPlaybackQualityMetrics;
+
 class VideoPlaybackQuality : public RefCounted<VideoPlaybackQuality> {
     WTF_MAKE_NONCOPYABLE(VideoPlaybackQuality)
 public:
-    static Ref<VideoPlaybackQuality> create(double creationTime, unsigned totalVideoFrames, unsigned droppedVideoFrames, unsigned corruptedVideoFrames, double totalFrameDelay);
+    static Ref<VideoPlaybackQuality> create(double creationTime, const VideoPlaybackQualityMetrics&);
 
     double creationTime() const { return m_creationTime; }
     unsigned totalVideoFrames() const { return m_totalVideoFrames; }
     unsigned droppedVideoFrames() const { return m_droppedVideoFrames; }
     unsigned corruptedVideoFrames() const { return m_corruptedVideoFrames; }
+    unsigned displayCompositedVideoFrames() const { return m_displayCompositedVideoFrames; }
     double totalFrameDelay() const { return m_totalFrameDelay; }
 
 private:
-    VideoPlaybackQuality(double creationTime, unsigned totalVideoFrames, unsigned droppedVideoFrames, unsigned corruptedVideoFrames, double totalFrameDelay);
+    VideoPlaybackQuality(double creationTime, const VideoPlaybackQualityMetrics&);
 
     double m_creationTime;
-    unsigned m_totalVideoFrames;
-    unsigned m_droppedVideoFrames;
-    unsigned m_corruptedVideoFrames;
+    uint32_t m_totalVideoFrames;
+    uint32_t m_droppedVideoFrames;
+    uint32_t m_corruptedVideoFrames;
+    uint32_t m_displayCompositedVideoFrames;
     double m_totalFrameDelay;
 };
 
index e78d0eb..46aef21 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 [
-    Conditional=MEDIA_SOURCE,
     NoInterfaceObject,
     ImplementationLacksVTable,
 ] interface VideoPlaybackQuality {
@@ -32,8 +31,6 @@
     readonly attribute unsigned long totalVideoFrames;
     readonly attribute unsigned long droppedVideoFrames;
     readonly attribute unsigned long corruptedVideoFrames;
+    [EnabledBySetting=videoQualityIncludesDisplayCompositing] readonly attribute unsigned long displayCompositedVideoFrames;
     readonly attribute unrestricted double totalFrameDelay;
 };
-
-
-
index 5fd7b67..7b73a9e 100644 (file)
@@ -1,3 +1,12 @@
+2018-10-04  Jer Noble  <jer.noble@apple.com>
+
+        Add support for reporting "display composited video frames" through the VideoPlaybackQuality object.
+        https://bugs.webkit.org/show_bug.cgi?id=190266
+
+        Reviewed by Eric Carlson.
+
+        * pal/spi/mac/AVFoundationSPI.h:
+
 2018-10-04  Dan Bernstein  <mitz@apple.com>
 
         PAL change for the WebKitLegacy part of [Xcode] Update some build settings as recommended by Xcode 10
index 5b6b80f..0fb9c98 100644 (file)
@@ -52,6 +52,7 @@
 
 #import <AVFoundation/AVPlayer.h>
 #import <AVFoundation/AVPlayerItem.h>
+#import <AVFoundation/AVPlayerLayer.h>
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000)
 NS_ASSUME_NONNULL_BEGIN
@@ -164,7 +165,7 @@ NS_ASSUME_NONNULL_END
 @property (nonatomic, readonly) unsigned long totalNumberOfVideoFrames;
 @property (nonatomic, readonly) unsigned long numberOfDroppedVideoFrames;
 @property (nonatomic, readonly) unsigned long numberOfCorruptedVideoFrames;
-@property (nonatomic, readonly) unsigned long numberOfNonDisplayCompositedVideoFrames;
+@property (nonatomic, readonly) unsigned long numberOfDisplayCompositedVideoFrames;
 @property (nonatomic, readonly) double totalFrameDelay;
 @end
 #endif
@@ -184,6 +185,13 @@ NS_ASSUME_NONNULL_END
 @end
 #endif // !HAVE(AVKIT)
 
+#if !USE(APPLE_INTERNAL_SDK) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101404) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED < 110000)
+NS_ASSUME_NONNULL_BEGIN
+@interface AVPlayerLayer (AVPlayerLayerVideoPerformanceMetrics)
+- (AVVideoPerformanceMetrics *)videoPerformanceMetrics;
+@end
+NS_ASSUME_NONNULL_END
+#endif
 
 // FIXME: Wrap in a #if USE(APPLE_INTERNAL_SDK) once these SPI land
 #import <AVFoundation/AVAsset.h>
index 91b958a..f8bc5b4 100644 (file)
@@ -89,6 +89,7 @@
 #include "TimeRanges.h"
 #include "UserContentController.h"
 #include "UserGestureIndicator.h"
+#include "VideoPlaybackQuality.h"
 #include <JavaScriptCore/Uint8Array.h>
 #include <limits>
 #include <pal/SessionID.h>
 #if ENABLE(MEDIA_SOURCE)
 #include "DOMWindow.h"
 #include "MediaSource.h"
-#include "VideoPlaybackQuality.h"
 #endif
 
 #if ENABLE(MEDIA_STREAM)
@@ -7149,7 +7149,6 @@ void HTMLMediaElement::updateRateChangeRestrictions()
         m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequireUserGestureForAudioRateChange);
 }
 
-#if ENABLE(MEDIA_SOURCE)
 RefPtr<VideoPlaybackQuality> HTMLMediaElement::getVideoPlaybackQuality()
 {
     RefPtr<DOMWindow> domWindow = document().domWindow();
@@ -7157,16 +7156,16 @@ RefPtr<VideoPlaybackQuality> HTMLMediaElement::getVideoPlaybackQuality()
 
     auto metrics = m_player ? m_player->videoPlaybackQualityMetrics() : std::nullopt;
     if (!metrics)
-        return VideoPlaybackQuality::create(timestamp, 0, 0, 0, 0);
+        return VideoPlaybackQuality::create(timestamp, { });
 
-    return VideoPlaybackQuality::create(timestamp,
-        metrics.value().totalVideoFrames + m_droppedVideoFrames,
-        metrics.value().droppedVideoFrames + m_droppedVideoFrames,
-        metrics.value().corruptedVideoFrames,
-        metrics.value().totalFrameDelay);
-}
+#if ENABLE(MEDIA_SOURCE)
+    metrics.value().totalVideoFrames += m_droppedVideoFrames;
+    metrics.value().droppedVideoFrames += m_droppedVideoFrames;
 #endif
 
+    return VideoPlaybackQuality::create(timestamp, metrics.value());
+}
+
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
 DOMWrapperWorld& HTMLMediaElement::ensureIsolatedWorld()
 {
index 6fb2cb8..7417219 100644 (file)
@@ -503,9 +503,7 @@ public:
     uint64_t elementID() const { return m_elementID; }
 #endif
 
-#if ENABLE(MEDIA_SOURCE)
     RefPtr<VideoPlaybackQuality> getVideoPlaybackQuality();
-#endif
 
     MediaPlayerEnums::Preload preloadValue() const { return m_preload; }
     MediaElementSession& mediaSession() const { return *m_mediaSession; }
index 927ac8f..a3d0208 100644 (file)
@@ -118,7 +118,7 @@ typedef (
 
     [ImplementedAs=controllerForBindings] attribute MediaController? controller;
 
-    [Conditional=MEDIA_SOURCE] VideoPlaybackQuality getVideoPlaybackQuality();
+    VideoPlaybackQuality getVideoPlaybackQuality();
 
     [Conditional=WIRELESS_PLAYBACK_TARGET] void webkitShowPlaybackTargetPicker();
     [Conditional=WIRELESS_PLAYBACK_TARGET] readonly attribute boolean webkitCurrentPlaybackTargetIsWireless;
index a9571f5..e91ee30 100644 (file)
@@ -762,3 +762,7 @@ shouldDeferAsynchronousScriptsUntilAfterDocumentLoad:
 
 shouldIgnoreMetaViewport:
   initial: false
+
+videoQualityIncludesDisplayCompositingEnabled:
+  initial: false
+  conditional: VIDEO
index 105a80f..a86c8db 100644 (file)
@@ -1450,7 +1450,6 @@ bool MediaPlayer::ended() const
     return m_private->ended();
 }
 
-#if ENABLE(MEDIA_SOURCE)
 std::optional<VideoPlaybackQualityMetrics> MediaPlayer::videoPlaybackQualityMetrics()
 {
     if (!m_private)
@@ -1458,7 +1457,6 @@ std::optional<VideoPlaybackQualityMetrics> MediaPlayer::videoPlaybackQualityMetr
 
     return m_private->videoPlaybackQualityMetrics();
 }
-#endif
 
 void MediaPlayer::handlePlaybackCommand(PlatformMediaSession::RemoteControlCommandType command)
 {
index 462a726..4809de3 100644 (file)
@@ -87,10 +87,11 @@ struct MediaEngineSupportParameters {
 };
 
 struct VideoPlaybackQualityMetrics {
-    unsigned totalVideoFrames;
-    unsigned droppedVideoFrames;
-    unsigned corruptedVideoFrames;
-    double totalFrameDelay;
+    uint32_t totalVideoFrames { 0 };
+    uint32_t droppedVideoFrames { 0 };
+    uint32_t corruptedVideoFrames { 0 };
+    double totalFrameDelay { 0 };
+    uint32_t displayCompositedVideoFrames { 0 };
 };
 
 class MediaPlayerClient {
@@ -540,9 +541,7 @@ public:
 
     unsigned long long fileSize() const;
 
-#if ENABLE(MEDIA_SOURCE)
     std::optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics();
-#endif
 
     void handlePlaybackCommand(PlatformMediaSession::RemoteControlCommandType);
     String sourceApplicationIdentifier() const;
index 2413da5..974e7e5 100644 (file)
@@ -265,9 +265,7 @@ public:
 
     virtual bool ended() const { return false; }
 
-#if ENABLE(MEDIA_SOURCE)
     virtual std::optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() { return std::nullopt; }
-#endif
 
 #if ENABLE(AVF_CAPTIONS)
     virtual void notifyTrackModeChanged() { }
index a2503e6..a9c5d56 100644 (file)
@@ -322,6 +322,8 @@ private:
 
     void setShouldDisableSleep(bool) override;
 
+    std::optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() final;
+
 #if !RELEASE_LOG_DISABLED
     const char* logClassName() const final { return "MediaPlayerPrivateAVFoundationObjC"; }
 #endif
index 7d49d4e..088dd21 100644 (file)
@@ -3258,6 +3258,32 @@ void MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep(bool flag)
 #endif
 }
 
+std::optional<VideoPlaybackQualityMetrics> MediaPlayerPrivateAVFoundationObjC::videoPlaybackQualityMetrics()
+{
+    if (![m_videoLayer respondsToSelector:@selector(videoPerformanceMetrics)])
+        return std::nullopt;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+    auto metrics = [m_videoLayer videoPerformanceMetrics];
+    if (!metrics)
+        return std::nullopt;
+
+    uint32_t displayCompositedFrames = 0;
+    if ([metrics respondsToSelector:@selector(numberOfDisplayCompositedVideoFrames)])
+        displayCompositedFrames = [metrics numberOfDisplayCompositedVideoFrames];
+#pragma clang diagnostic pop
+
+    return VideoPlaybackQualityMetrics {
+        static_cast<uint32_t>([metrics totalNumberOfVideoFrames]),
+        static_cast<uint32_t>([metrics numberOfDroppedVideoFrames]),
+        static_cast<uint32_t>([metrics numberOfCorruptedVideoFrames]),
+        [metrics totalFrameDelay],
+        displayCompositedFrames,
+    };
+}
+
 NSArray* assetMetadataKeyNames()
 {
     static NSArray* keys = [[NSArray alloc] initWithObjects:
index e423663..7a12b2e 100644 (file)
@@ -650,7 +650,8 @@ std::optional<VideoPlaybackQualityMetrics> MediaPlayerPrivateMediaSourceAVFObjC:
             m_decompressionSession->totalVideoFrames(),
             m_decompressionSession->droppedVideoFrames(),
             m_decompressionSession->corruptedVideoFrames(),
-            m_decompressionSession->totalFrameDelay().toDouble()
+            m_decompressionSession->totalFrameDelay().toDouble(),
+            0,
         };
     }
 
@@ -658,11 +659,20 @@ std::optional<VideoPlaybackQualityMetrics> MediaPlayerPrivateMediaSourceAVFObjC:
     if (!metrics)
         return std::nullopt;
 
+    uint32_t displayCompositedFrames = 0;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+    if ([metrics respondsToSelector:@selector(numberOfDisplayCompositedVideoFrames)])
+        displayCompositedFrames = [metrics numberOfDisplayCompositedVideoFrames];
+#pragma clang diagnostic pop
+
     return VideoPlaybackQualityMetrics {
-        static_cast<unsigned>([metrics totalNumberOfVideoFrames]),
-        static_cast<unsigned>([metrics numberOfDroppedVideoFrames]),
-        static_cast<unsigned>([metrics numberOfCorruptedVideoFrames]),
-        [metrics totalFrameDelay]
+        static_cast<uint32_t>([metrics totalNumberOfVideoFrames]),
+        static_cast<uint32_t>([metrics numberOfDroppedVideoFrames]),
+        static_cast<uint32_t>([metrics numberOfCorruptedVideoFrames]),
+        [metrics totalFrameDelay],
+        displayCompositedFrames,
     };
 }
 
index 5f8215e..abc3ba5 100644 (file)
@@ -177,7 +177,8 @@ std::optional<VideoPlaybackQualityMetrics> MockMediaSourcePrivate::videoPlayback
         m_totalVideoFrames,
         m_droppedVideoFrames,
         m_corruptedVideoFrames,
-        m_totalFrameDelay.toDouble()
+        m_totalFrameDelay.toDouble(),
+        0,
     };
 }
 
index 3d0d18f..2821cc5 100644 (file)
@@ -1,3 +1,18 @@
+2018-10-04  Jer Noble  <jer.noble@apple.com>
+
+        Add support for reporting "display composited video frames" through the VideoPlaybackQuality object.
+        https://bugs.webkit.org/show_bug.cgi?id=190266
+
+        Reviewed by Eric Carlson.
+
+        Add a new preference to control the visibility of displayCompositedVideoFrames in the VideoPlaybackQualityObject.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setVideoQualityIncludesDisplayCompositingEnabled:]):
+        (-[WKPreferences _videoQualityIncludesDisplayCompositingEnabled]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
 2018-10-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Cocoa] Add SPI to expose typing attributes at the current selection on WKWebView
index 9c99b65..1309fb1 100644 (file)
@@ -1146,6 +1146,11 @@ EncryptedMediaAPIEnabled:
   webcoreBinding: RuntimeEnabledFeatures
   condition: ENABLE(ENCRYPTED_MEDIA)
 
+VideoQualityIncludesDisplayCompositingEnabled:
+  type: bool
+  defaultValue: false
+  condition: ENABLE(VIDEO)
+
 # For experimental features:
 # The type should be boolean.
 # You must provide a humanReadableName and humanReadableDescription for all experimental features. They
index 4a3658b..e00b3bf 100644 (file)
@@ -1326,6 +1326,16 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
 #endif
 }
 
+- (void)_setVideoQualityIncludesDisplayCompositingEnabled:(BOOL)videoQualityIncludesDisplayCompositingEnabled
+{
+    _preferences->setVideoQualityIncludesDisplayCompositingEnabled(videoQualityIncludesDisplayCompositingEnabled);
+}
+
+- (BOOL)_videoQualityIncludesDisplayCompositingEnabled
+{
+    return _preferences->videoQualityIncludesDisplayCompositingEnabled();
+}
+
 @end
 
 #endif // WK_API_ENABLED
index a3762e6..881e3a0 100644 (file)
@@ -148,6 +148,7 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
 @property (nonatomic, setter=_setPunchOutWhiteBackgroundsInDarkMode:) BOOL _punchOutWhiteBackgroundsInDarkMode WK_API_AVAILABLE(macosx(10.14), ios(12.0));
 @property (nonatomic, setter=_setLowPowerVideoAudioBufferSizeEnabled:) BOOL _lowPowerVideoAudioBufferSizeEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setShouldIgnoreMetaViewport:) BOOL _shouldIgnoreMetaViewport WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setVideoQualityIncludesDisplayCompositingEnabled:) BOOL _videoQualityIncludesDisplayCompositingEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(10.13.4));
index c5faea6..c55240b 100644 (file)
@@ -1,3 +1,14 @@
+2018-10-04  Jer Noble  <jer.noble@apple.com>
+
+        Add support for reporting "display composited video frames" through the VideoPlaybackQuality object.
+        https://bugs.webkit.org/show_bug.cgi?id=190266
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm: Added.
+        (TestWebKitAPI::TEST):
+
 2018-10-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Cocoa] Add SPI to expose typing attributes at the current selection on WKWebView
index a50f547..2199d2d 100644 (file)
                CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */; };
                CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD227E43211A4D5D00D285AF /* PreferredAudioBufferSize.mm */; };
                CD2D0D1A213465560018C784 /* NowPlaying.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD2D0D19213465560018C784 /* NowPlaying.mm */; };
+               CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */; };
                CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */; };
                CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD577798211CDE8F001B371E /* web-audio-only.html */; };
                CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD57779A211CE6B7001B371E /* audio-with-web-audio.html */; };
                CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; };
                CD227E43211A4D5D00D285AF /* PreferredAudioBufferSize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredAudioBufferSize.mm; sourceTree = "<group>"; };
                CD2D0D19213465560018C784 /* NowPlaying.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlaying.mm; sourceTree = "<group>"; };
+               CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoQualityDisplayCompositing.mm; sourceTree = "<group>"; };
                CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio-and-webaudio.html"; sourceTree = "<group>"; };
                CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
                CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = "<group>"; };
                                07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */,
                                07F4E92D20AF58D3002E3803 /* UserMediaSimulateFailedSandbox.mm */,
                                93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */,
+                               CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */,
                                6356FB211EC4E0BA0044BF18 /* VisibleContentRect.mm */,
                                83779C371F82FEB0007CDA8A /* VisitedLinkStore.mm */,
                                830F2E0B209A6A7400D36FF1 /* WebContentProcessDidTerminate.mm */,
                                7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */,
                                7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
                                7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
+                               CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */,
                                115EB3431EE0BA03003C2C0A /* ViewportSizeForViewportUnits.mm in Sources */,
                                6356FB221EC4E0BA0044BF18 /* VisibleContentRect.mm in Sources */,
                                83779C381F82FECE007CDA8A /* VisitedLinkStore.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm
new file mode 100644 (file)
index 0000000..633bff7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "Test.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+namespace TestWebKitAPI {
+
+TEST(VideoQualityDisplayCompositing, Enabled)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get().preferences._videoQualityIncludesDisplayCompositingEnabled = YES;
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+    [webView synchronouslyLoadHTMLString:@"<video>"];
+    id result = [webView objectByEvaluatingJavaScript:@"document.querySelector('video').getVideoPlaybackQuality().displayCompositedVideoFrames"];
+    EXPECT_NOT_NULL(result);
+    EXPECT_TRUE([result isKindOfClass:[NSNumber class]]);
+    EXPECT_EQ(0, [result intValue]);
+}
+
+TEST(VideoQualityDisplayCompositing, Disabled)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get().preferences._videoQualityIncludesDisplayCompositingEnabled = NO;
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+    [webView synchronouslyLoadHTMLString:@"<video>"];
+    auto result = [webView stringByEvaluatingJavaScript:@"typeof document.querySelector('video').getVideoPlaybackQuality().displayCompositedVideoFrames"];
+    EXPECT_STREQ("undefined", result.UTF8String);
+}
+
+}
+
+#endif