Title: [291670] branches/safari-613-branch/Source
Revision
291670
Author
alanc...@apple.com
Date
2022-03-22 10:57:03 -0700 (Tue, 22 Mar 2022)

Log Message

Cherry-pick r291326. rdar://problem/85551863

    Video poster disappears prematurely on play, leaving transparent video element.
    https://bugs.webkit.org/show_bug.cgi?id=226960
    <rdar://problem/79315114>

    Reviewed by Jer Noble.

    Source/WebCore:

    If a media file has an enabled video track, don't advance readyState to
    HAVE_ENOUGH_DATA until we have the first frame so we won't hide the poster image
    until AVFoundation has something to render.

    Tested manually.

    * html/HTMLVideoElement.cpp:
    (WebCore::HTMLVideoElement::mediaPlayerFirstVideoFrameAvailable): Always log.

    * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
    (WebCore::MediaPlayerPrivateAVFoundation::updateStates): Move the test for the
    first video frame above the player item status check. If a file has a video track,
    don't advance to HAVE_ENOUGH_DATA unless we have the first video frame.

    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
    (WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear m_cachedHasEnabledVideo.
    (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Remove unneeded
    local variable.
    (WebCore::MediaPlayerPrivateAVFoundationObjC::platformSetVisible): Minro cleanup.
    (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Set `hasVideo` if
    AVPlayerItem.hasEnabledVideo is true, because it remains stable while AVAssetTracks
    sometimes disappear and reappear.
    (WebCore::MediaPlayerPrivateAVFoundationObjC::firstFrameAvailableDidChange): Add logging.
    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange): Ditto
    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledVideoDidChange): New, cache
    AVPlayerItem.hasEnabledVideo.
    (WebCore::itemKVOProperties):
    (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): Respond
    to @"hasEnabledVideo".
    * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:

    Source/WebKit:

    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
    (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): Always log.
    (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote): Ditto.
    (WebKit::MediaPlayerPrivateRemote::prepareForPlayback): Pass the player's content
    rect box to createVideoLayerRemote so it can be sized correctly even before it
    becomes visible.
    (WebKit::MediaPlayerPrivateRemote::firstVideoFrameAvailable): Always log.
    (WebKit::MediaPlayerPrivateRemote::renderingModeChanged): Ditto.
    * WebProcess/GPU/media/VideoLayerRemote.h:

    * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm:
    (WebKit::createVideoLayerRemote): Set the new layer's frame so its children will
    be positioned correctly when the are made visible.

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

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-22 17:57:03 UTC (rev 291670)
@@ -1,5 +1,108 @@
 2022-03-21  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r291326. rdar://problem/85551863
+
+    Video poster disappears prematurely on play, leaving transparent video element.
+    https://bugs.webkit.org/show_bug.cgi?id=226960
+    <rdar://problem/79315114>
+    
+    Reviewed by Jer Noble.
+    
+    Source/WebCore:
+    
+    If a media file has an enabled video track, don't advance readyState to
+    HAVE_ENOUGH_DATA until we have the first frame so we won't hide the poster image
+    until AVFoundation has something to render.
+    
+    Tested manually.
+    
+    * html/HTMLVideoElement.cpp:
+    (WebCore::HTMLVideoElement::mediaPlayerFirstVideoFrameAvailable): Always log.
+    
+    * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+    (WebCore::MediaPlayerPrivateAVFoundation::updateStates): Move the test for the
+    first video frame above the player item status check. If a file has a video track,
+    don't advance to HAVE_ENOUGH_DATA unless we have the first video frame.
+    
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear m_cachedHasEnabledVideo.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Remove unneeded
+    local variable.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::platformSetVisible): Minro cleanup.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Set `hasVideo` if
+    AVPlayerItem.hasEnabledVideo is true, because it remains stable while AVAssetTracks
+    sometimes disappear and reappear.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::firstFrameAvailableDidChange): Add logging.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange): Ditto
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledVideoDidChange): New, cache
+    AVPlayerItem.hasEnabledVideo.
+    (WebCore::itemKVOProperties):
+    (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): Respond
+    to @"hasEnabledVideo".
+    * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
+    
+    Source/WebKit:
+    
+    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+    (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): Always log.
+    (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote): Ditto.
+    (WebKit::MediaPlayerPrivateRemote::prepareForPlayback): Pass the player's content
+    rect box to createVideoLayerRemote so it can be sized correctly even before it
+    becomes visible.
+    (WebKit::MediaPlayerPrivateRemote::firstVideoFrameAvailable): Always log.
+    (WebKit::MediaPlayerPrivateRemote::renderingModeChanged): Ditto.
+    * WebProcess/GPU/media/VideoLayerRemote.h:
+    
+    * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm:
+    (WebKit::createVideoLayerRemote): Set the new layer's frame so its children will
+    be positioned correctly when the are made visible.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-03-15  Eric Carlson  <eric.carl...@apple.com>
+
+            Video poster disappears prematurely on play, leaving transparent video element.
+            https://bugs.webkit.org/show_bug.cgi?id=226960
+            <rdar://problem/79315114>
+
+            Reviewed by Jer Noble.
+
+            If a media file has an enabled video track, don't advance readyState to
+            HAVE_ENOUGH_DATA until we have the first frame so we won't hide the poster image
+            until AVFoundation has something to render.
+
+            Tested manually.
+
+            * html/HTMLVideoElement.cpp:
+            (WebCore::HTMLVideoElement::mediaPlayerFirstVideoFrameAvailable): Always log.
+
+            * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+            (WebCore::MediaPlayerPrivateAVFoundation::updateStates): Move the test for the
+            first video frame above the player item status check. If a file has a video track,
+            don't advance to HAVE_ENOUGH_DATA unless we have the first video frame.
+
+            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear m_cachedHasEnabledVideo.
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Remove unneeded
+            local variable.
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::platformSetVisible): Minro cleanup.
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Set `hasVideo` if
+            AVPlayerItem.hasEnabledVideo is true, because it remains stable while AVAssetTracks
+            sometimes disappear and reappear.
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::firstFrameAvailableDidChange): Add logging.
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange): Ditto
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledVideoDidChange): New, cache
+            AVPlayerItem.hasEnabledVideo.
+            (WebCore::itemKVOProperties):
+            (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): Respond
+            to @"hasEnabledVideo".
+            * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
+
+2022-03-21  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r291324. rdar://problem/45607220
 
     Crash under HTMLDocumentParser::didBeginYieldingParser()

Modified: branches/safari-613-branch/Source/WebCore/html/HTMLVideoElement.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/html/HTMLVideoElement.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/html/HTMLVideoElement.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -271,7 +271,7 @@
 
 void HTMLVideoElement::mediaPlayerFirstVideoFrameAvailable()
 {
-    INFO_LOG(LOGIDENTIFIER, "m_showPoster = ", showPosterFlag());
+    ALWAYS_LOG(LOGIDENTIFIER, "m_showPoster = ", showPosterFlag());
 
     if (showPosterFlag())
         return;

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -505,6 +505,7 @@
 
     MediaPlayer::NetworkState newNetworkState = m_networkState;
     MediaPlayer::ReadyState newReadyState = m_readyState;
+    bool firstVideoFrameBecomeAvailable = false;
 
     if (m_loadingMetadata)
         newNetworkState = MediaPlayer::NetworkState::Loading;
@@ -533,7 +534,14 @@
                 newNetworkState = MediaPlayer::NetworkState::FormatError;
             }
         }
-        
+
+        if (!hasAvailableVideoFrame())
+            m_haveReportedFirstVideoFrame = false;
+        else if (!m_haveReportedFirstVideoFrame && m_cachedHasVideo) {
+            m_haveReportedFirstVideoFrame = true;
+            firstVideoFrameBecomeAvailable = true;
+        }
+
         if (assetStatus >= MediaPlayerAVAssetStatusLoaded && itemStatus > MediaPlayerAVPlayerItemStatusUnknown) {
             switch (itemStatus) {
             case MediaPlayerAVPlayerItemStatusDoesNotExist:
@@ -544,13 +552,13 @@
             case MediaPlayerAVPlayerItemStatusPlaybackLikelyToKeepUp:
             case MediaPlayerAVPlayerItemStatusPlaybackBufferFull:
                 // If the status becomes PlaybackBufferFull, loading stops and the status will not
-                // progress to LikelyToKeepUp. Set the readyState to  HAVE_ENOUGH_DATA, on the
+                // progress to LikelyToKeepUp. Set the readyState to HAVE_ENOUGH_DATA, on the
                 // presumption that if the playback buffer is full, playback will probably not stall.
                 newReadyState = MediaPlayer::ReadyState::HaveEnoughData;
                 break;
 
             case MediaPlayerAVPlayerItemStatusReadyToPlay:
-                if (m_readyState != MediaPlayer::ReadyState::HaveEnoughData && maxTimeLoaded() > currentMediaTime())
+                if (m_readyState != MediaPlayer::ReadyState::HaveEnoughData && (!m_cachedHasVideo || m_haveReportedFirstVideoFrame) && maxTimeLoaded() > currentMediaTime())
                     newReadyState = MediaPlayer::ReadyState::HaveFutureData;
                 break;
 
@@ -571,13 +579,11 @@
     if (isReadyForVideoSetup() && currentRenderingMode() != preferredRenderingMode())
         setUpVideoRendering();
 
-    if (!m_haveReportedFirstVideoFrame && m_cachedHasVideo && hasAvailableVideoFrame()) {
+    if (firstVideoFrameBecomeAvailable) {
         if (m_readyState < MediaPlayer::ReadyState::HaveCurrentData)
             newReadyState = MediaPlayer::ReadyState::HaveCurrentData;
-        m_haveReportedFirstVideoFrame = true;
         m_player->firstVideoFrameAvailable();
-    } else if (!hasAvailableVideoFrame())
-        m_haveReportedFirstVideoFrame = false;
+    }
 
     if (m_networkState != newNetworkState)
         ALWAYS_LOG(LOGIDENTIFIER, "entered with networkState ", m_networkState, ", exiting with ", newNetworkState);

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2022-03-22 17:57:03 UTC (rev 291670)
@@ -107,6 +107,7 @@
     void seekableTimeRangesDidChange(RetainPtr<NSArray>&&, NSTimeInterval, NSTimeInterval);
     void tracksDidChange(const RetainPtr<NSArray>&);
     void hasEnabledAudioDidChange(bool);
+    void hasEnabledVideoDidChange(bool);
     void presentationSizeDidChange(FloatSize);
     void durationDidChange(const MediaTime&);
     void rateDidChange(double);
@@ -443,6 +444,7 @@
     bool m_cachedBufferEmpty { false };
     bool m_cachedBufferFull { false };
     bool m_cachedHasEnabledAudio { false };
+    bool m_cachedHasEnabledVideo { false };
     bool m_cachedIsReadyForDisplay { false };
     bool m_haveBeenAskedToCreateLayer { false };
     bool m_cachedCanPlayFastForward { false };

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-03-22 17:57:03 UTC (rev 291670)
@@ -536,6 +536,7 @@
     m_cachedSeekableRanges = nullptr;
     m_cachedLoadedRanges = nullptr;
     m_cachedHasEnabledAudio = false;
+    m_cachedHasEnabledVideo = false;
     m_cachedPresentationSize = FloatSize();
     m_cachedDuration = MediaTime::zeroTime();
 
@@ -635,11 +636,8 @@
     [m_videoLayer addObserver:m_objcObserver.get() forKeyPath:@"readyForDisplay" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextAVPlayerLayer];
     updateVideoLayerGravity();
     [m_videoLayer setContentsScale:player()->playerContentsScale()];
-    IntSize defaultSize = snappedIntRect(player()->playerContentBoxRect()).size();
-    ALWAYS_LOG(LOGIDENTIFIER);
+    m_videoLayerManager->setVideoLayer(m_videoLayer.get(), snappedIntRect(player()->playerContentBoxRect()).size());
 
-    m_videoLayerManager->setVideoLayer(m_videoLayer.get(), defaultSize);
-
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
     if ([m_videoLayer respondsToSelector:@selector(setPIPModeEnabled:)])
         [m_videoLayer setPIPModeEnabled:(player()->fullscreenMode() & MediaPlayer::VideoFullscreenModePictureInPicture)];
@@ -1373,10 +1371,12 @@
 
 void MediaPlayerPrivateAVFoundationObjC::platformSetVisible(bool isVisible)
 {
+    if (!m_videoLayer)
+        return;
+
     [CATransaction begin];
     [CATransaction setDisableActions:YES];    
-    if (m_videoLayer)
-        [m_videoLayer setHidden:!isVisible];
+    [m_videoLayer setHidden:!isVisible];
     [CATransaction commit];
 }
     
@@ -2215,10 +2215,12 @@
         // whethere there is any audio present.
         hasAudio |= m_cachedHasEnabledAudio;
 
-        // Always says we have video if the AVPlayerLayer is ready for diaplay to work around
+        // Always says we have video if the AVPlayerLayer is ready for display to work around
         // an AVFoundation bug which causes it to sometimes claim a track is disabled even
-        // when it is not.
-        setHasVideo(hasVideo || m_cachedIsReadyForDisplay);
+        // when it is not. Also say we have video if AVPlayerItem's `hasEnabledVideo` is true,
+        // as an AVAssetTrack will sometimes disappear briefly and reappear when `hasEnabledVideo`
+        // doesn't change.
+        setHasVideo(hasVideo || m_cachedIsReadyForDisplay || m_cachedHasEnabledVideo);
 
         setHasAudio(hasAudio);
 #if ENABLE(DATACUE_VALUE)
@@ -3347,6 +3349,8 @@
 
 void MediaPlayerPrivateAVFoundationObjC::firstFrameAvailableDidChange(bool isReady)
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     m_cachedIsReadyForDisplay = isReady;
     if (!hasVideo() && isReady)
         tracksChanged();
@@ -3541,6 +3545,7 @@
 
 void MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange(bool hasEnabledAudio)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, hasEnabledAudio);
     m_cachedHasEnabledAudio = hasEnabledAudio;
 
     tracksChanged();
@@ -3547,6 +3552,15 @@
     updateStates();
 }
 
+void MediaPlayerPrivateAVFoundationObjC::hasEnabledVideoDidChange(bool hasEnabledVideo)
+{
+    ALWAYS_LOG(LOGIDENTIFIER, hasEnabledVideo);
+    m_cachedHasEnabledVideo = hasEnabledVideo;
+
+    tracksChanged();
+    updateStates();
+}
+
 void MediaPlayerPrivateAVFoundationObjC::presentationSizeDidChange(FloatSize size)
 {
     m_cachedPresentationSize = size;
@@ -3744,6 +3758,7 @@
         @"playbackBufferEmpty",
         @"duration",
         @"hasEnabledAudio",
+        @"hasEnabledVideo",
         @"canPlayFastForward",
         @"canPlayFastReverse",
     nil];
@@ -3906,6 +3921,8 @@
                 shouldLogValue = false;
             } else if ([keyPath isEqualToString:@"hasEnabledAudio"])
                 player.hasEnabledAudioDidChange([newValue boolValue]);
+            else if ([keyPath isEqualToString:@"hasEnabledVideo"])
+                player.hasEnabledVideoDidChange([newValue boolValue]);
             else if ([keyPath isEqualToString:@"presentationSize"])
                 player.presentationSizeDidChange(FloatSize([newValue sizeValue]));
             else if ([keyPath isEqualToString:@"duration"])

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h (291669 => 291670)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h	2022-03-22 17:57:03 UTC (rev 291670)
@@ -59,7 +59,7 @@
 
     WEBCORE_EXPORT PlatformLayer* videoInlineLayer() const final;
 
-    WEBCORE_EXPORT void setVideoLayer(PlatformLayer*, IntSize contentSize) final;
+    WEBCORE_EXPORT void setVideoLayer(PlatformLayer*, IntSize) final;
     WEBCORE_EXPORT void didDestroyVideoLayer() final;
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-22 17:57:03 UTC (rev 291670)
@@ -1,5 +1,90 @@
 2022-03-21  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r291326. rdar://problem/85551863
+
+    Video poster disappears prematurely on play, leaving transparent video element.
+    https://bugs.webkit.org/show_bug.cgi?id=226960
+    <rdar://problem/79315114>
+    
+    Reviewed by Jer Noble.
+    
+    Source/WebCore:
+    
+    If a media file has an enabled video track, don't advance readyState to
+    HAVE_ENOUGH_DATA until we have the first frame so we won't hide the poster image
+    until AVFoundation has something to render.
+    
+    Tested manually.
+    
+    * html/HTMLVideoElement.cpp:
+    (WebCore::HTMLVideoElement::mediaPlayerFirstVideoFrameAvailable): Always log.
+    
+    * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+    (WebCore::MediaPlayerPrivateAVFoundation::updateStates): Move the test for the
+    first video frame above the player item status check. If a file has a video track,
+    don't advance to HAVE_ENOUGH_DATA unless we have the first video frame.
+    
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+    * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear m_cachedHasEnabledVideo.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Remove unneeded
+    local variable.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::platformSetVisible): Minro cleanup.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Set `hasVideo` if
+    AVPlayerItem.hasEnabledVideo is true, because it remains stable while AVAssetTracks
+    sometimes disappear and reappear.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::firstFrameAvailableDidChange): Add logging.
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange): Ditto
+    (WebCore::MediaPlayerPrivateAVFoundationObjC::hasEnabledVideoDidChange): New, cache
+    AVPlayerItem.hasEnabledVideo.
+    (WebCore::itemKVOProperties):
+    (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): Respond
+    to @"hasEnabledVideo".
+    * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
+    
+    Source/WebKit:
+    
+    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+    (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): Always log.
+    (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote): Ditto.
+    (WebKit::MediaPlayerPrivateRemote::prepareForPlayback): Pass the player's content
+    rect box to createVideoLayerRemote so it can be sized correctly even before it
+    becomes visible.
+    (WebKit::MediaPlayerPrivateRemote::firstVideoFrameAvailable): Always log.
+    (WebKit::MediaPlayerPrivateRemote::renderingModeChanged): Ditto.
+    * WebProcess/GPU/media/VideoLayerRemote.h:
+    
+    * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm:
+    (WebKit::createVideoLayerRemote): Set the new layer's frame so its children will
+    be positioned correctly when the are made visible.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-03-15  Eric Carlson  <eric.carl...@apple.com>
+
+            Video poster disappears prematurely on play, leaving transparent video element.
+            https://bugs.webkit.org/show_bug.cgi?id=226960
+            <rdar://problem/79315114>
+
+            Reviewed by Jer Noble.
+
+            * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+            (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): Always log.
+            (WebKit::MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote): Ditto.
+            (WebKit::MediaPlayerPrivateRemote::prepareForPlayback): Pass the player's content
+            rect box to createVideoLayerRemote so it can be sized correctly even before it
+            becomes visible.
+            (WebKit::MediaPlayerPrivateRemote::firstVideoFrameAvailable): Always log.
+            (WebKit::MediaPlayerPrivateRemote::renderingModeChanged): Ditto.
+            * WebProcess/GPU/media/VideoLayerRemote.h:
+
+            * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm:
+            (WebKit::createVideoLayerRemote): Set the new layer's frame so its children will
+            be positioned correctly when the are made visible.
+
+2022-03-21  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r291182. rdar://problem/88226412
 
     Delay responsiveness checks for the Network Process until it has finished initialization

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -121,7 +121,7 @@
     , m_id(playerIdentifier)
     , m_documentSecurityOrigin(player->documentSecurityOrigin())
 {
-    INFO_LOG(LOGIDENTIFIER);
+    ALWAYS_LOG(LOGIDENTIFIER);
 
     acceleratedRenderingStateChanged();
 }
@@ -128,7 +128,7 @@
 
 MediaPlayerPrivateRemote::~MediaPlayerPrivateRemote()
 {
-    INFO_LOG(LOGIDENTIFIER);
+    ALWAYS_LOG(LOGIDENTIFIER);
 #if PLATFORM(COCOA)
     m_videoLayerManager->didDestroyVideoLayer();
 #endif
@@ -160,9 +160,10 @@
         if (!player)
             return;
 
-        m_videoLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value(), m_videoFullscreenGravity);
+        auto contentBox = snappedIntRect(player->playerContentBoxRect()).size();
+        m_videoLayer = createVideoLayerRemote(this, inlineLayerHostingContextId.value(), m_videoFullscreenGravity, contentBox);
 #if PLATFORM(COCOA)
-        m_videoLayerManager->setVideoLayer(m_videoLayer.get(), snappedIntRect(player->playerContentBoxRect()).size());
+        m_videoLayerManager->setVideoLayer(m_videoLayer.get(), contentBox);
 #endif
     }, m_id);
 }
@@ -441,7 +442,7 @@
 
 void MediaPlayerPrivateRemote::firstVideoFrameAvailable()
 {
-    INFO_LOG(LOGIDENTIFIER);
+    ALWAYS_LOG(LOGIDENTIFIER);
     if (RefPtr player = m_player.get())
         player->firstVideoFrameAvailable();
 }
@@ -448,7 +449,7 @@
 
 void MediaPlayerPrivateRemote::renderingModeChanged()
 {
-    INFO_LOG(LOGIDENTIFIER);
+    ALWAYS_LOG(LOGIDENTIFIER);
     if (RefPtr player = m_player.get())
         player->renderingModeChanged();
 }

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/VideoLayerRemote.h (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/VideoLayerRemote.h	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/VideoLayerRemote.h	2022-03-22 17:57:03 UTC (rev 291670)
@@ -28,6 +28,7 @@
 #if ENABLE(GPU_PROCESS)
 
 #include "LayerHostingContext.h"
+#include <WebCore/IntSize.h>
 #include <WebCore/MediaPlayerEnums.h>
 #include <WebCore/PlatformLayer.h>
 
@@ -35,7 +36,7 @@
 
 class MediaPlayerPrivateRemote;
 
-PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity);
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity, WebCore::IntSize);
 
 } // namespace WebKit
 

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.mm	2022-03-22 17:57:03 UTC (rev 291670)
@@ -178,7 +178,7 @@
 
 namespace WebKit {
 
-PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote* mediaPlayerPrivateRemote, LayerHostingContextID contextId, WebCore::MediaPlayerEnums::VideoGravity videoGravity)
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote* mediaPlayerPrivateRemote, LayerHostingContextID contextId, WebCore::MediaPlayerEnums::VideoGravity videoGravity, IntSize contentSize)
 {
     // Initially, all the layers will be empty (both width and height are 0) and invisible.
     // The renderer will change the sizes of WKVideoLayerRemote to trigger layout of sublayers and make them visible.
@@ -186,7 +186,9 @@
     [videoLayerRemote setName:@"WKVideoLayerRemote"];
     [videoLayerRemote setVideoGravity:videoGravity];
     [videoLayerRemote setMediaPlayerPrivateRemote:mediaPlayerPrivateRemote];
-    [videoLayerRemote addSublayer:LayerHostingContext::createPlatformLayerForHostingContext(contextId).get()];
+    auto layerForHostContext = LayerHostingContext::createPlatformLayerForHostingContext(contextId).get();
+    [layerForHostContext setFrame:CGRectMake(0, 0, contentSize.width(), contentSize.height())];
+    [videoLayerRemote addSublayer:WTFMove(layerForHostContext)];
 
     return videoLayerRemote;
 }

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/gstreamer/VideoLayerRemoteGStreamer.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/gstreamer/VideoLayerRemoteGStreamer.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/gstreamer/VideoLayerRemoteGStreamer.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -41,7 +41,7 @@
 
 namespace WebKit {
 
-PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity)
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity, WebCore::IntSize)
 {
     notImplemented();
     return nullptr;

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -32,7 +32,7 @@
 
 namespace WebKit {
 
-PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity)
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity, WebCore::IntSize)
 {
     notImplemented();
     return nullptr;

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/win/VideoLayerRemoteWin.cpp (291669 => 291670)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/win/VideoLayerRemoteWin.cpp	2022-03-22 17:56:57 UTC (rev 291669)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/media/win/VideoLayerRemoteWin.cpp	2022-03-22 17:57:03 UTC (rev 291670)
@@ -33,7 +33,7 @@
 
 namespace WebKit {
 
-PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity)
+PlatformLayerContainer createVideoLayerRemote(MediaPlayerPrivateRemote*, LayerHostingContextID, WebCore::MediaPlayerEnums::VideoGravity, WebCore::IntSize)
 {
     notImplemented();
     return nullptr;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to