Title: [216766] trunk/Source/WebCore
Revision
216766
Author
jer.no...@apple.com
Date
2017-05-12 09:05:38 -0700 (Fri, 12 May 2017)

Log Message

[MediaStream] Streams while play while page is in background can get "stuck" when page is forgrounded.
https://bugs.webkit.org/show_bug.cgi?id=172022

Reviewed by Youenn Fablet.

When an AVSampleBufferDisplayLayer is disconnected from the CA renderer, none of its samples will be decoded
and enqueued for rendering. Once the layer is attached to a renderer again, it's stuffed full of samples which
will never be decoded as their decode time has long passed.

Pass the visibility state of the element through to the MediaPlayer so that MediaPlayerPrivateMediaStreamAVFObjC
can flush its renderers when going from not visible -> visible.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::visibilityStateChanged):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisible):
* rendering/RenderVideo.cpp:
(WebCore::RenderVideo::updatePlayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (216765 => 216766)


--- trunk/Source/WebCore/ChangeLog	2017-05-12 15:37:17 UTC (rev 216765)
+++ trunk/Source/WebCore/ChangeLog	2017-05-12 16:05:38 UTC (rev 216766)
@@ -1,3 +1,25 @@
+2017-05-12  Jer Noble  <jer.no...@apple.com>
+
+        [MediaStream] Streams while play while page is in background can get "stuck" when page is forgrounded.
+        https://bugs.webkit.org/show_bug.cgi?id=172022
+
+        Reviewed by Youenn Fablet.
+
+        When an AVSampleBufferDisplayLayer is disconnected from the CA renderer, none of its samples will be decoded
+        and enqueued for rendering. Once the layer is attached to a renderer again, it's stuffed full of samples which
+        will never be decoded as their decode time has long passed.
+
+        Pass the visibility state of the element through to the MediaPlayer so that MediaPlayerPrivateMediaStreamAVFObjC
+        can flush its renderers when going from not visible -> visible.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::visibilityStateChanged):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVisible):
+        * rendering/RenderVideo.cpp:
+        (WebCore::RenderVideo::updatePlayer):
+
 2017-05-12  Per Arne Vollan  <pvol...@apple.com>
 
         Unreviewed Windows build fix.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (216765 => 216766)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-05-12 15:37:17 UTC (rev 216765)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-05-12 16:05:38 UTC (rev 216766)
@@ -5355,6 +5355,8 @@
     LOG(Media, "HTMLMediaElement::visibilityStateChanged(%p) - visible = %s", this, boolString(!m_elementIsHidden));
     updateSleepDisabling();
     m_mediaSession->visibilityChanged();
+    if (m_player)
+        m_player->setVisible(!m_elementIsHidden);
 
     bool isPlayingAudio = isPlaying() && hasAudio() && !muted() && volume();
     if (!isPlayingAudio) {

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (216765 => 216766)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2017-05-12 15:37:17 UTC (rev 216765)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2017-05-12 16:05:38 UTC (rev 216766)
@@ -120,7 +120,7 @@
     bool hasVideo() const override;
     bool hasAudio() const override;
 
-    void setVisible(bool) override { /* No-op */ }
+    void setVisible(bool) final;
 
     MediaTime durationMediaTime() const override;
     MediaTime currentMediaTime() const override;
@@ -262,6 +262,7 @@
     bool m_pendingSelectedTrackCheck { false };
     bool m_shouldDisplayFirstVideoFrame { false };
     bool m_transformIsValid { false };
+    bool m_visible { false };
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     std::unique_ptr<VideoFullscreenLayerManager> m_videoFullscreenLayerManager;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (216765 => 216766)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2017-05-12 15:37:17 UTC (rev 216765)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2017-05-12 16:05:38 UTC (rev 216766)
@@ -696,6 +696,16 @@
     return m_mediaStreamPrivate->hasAudio();
 }
 
+void MediaPlayerPrivateMediaStreamAVFObjC::setVisible(bool visible)
+{
+    if (m_visible == visible)
+        return;
+
+    m_visible = visible;
+    if (m_visible)
+        flushRenderers();
+}
+
 MediaTime MediaPlayerPrivateMediaStreamAVFObjC::durationMediaTime() const
 {
     return MediaTime::positiveInfiniteTime();

Modified: trunk/Source/WebCore/rendering/RenderVideo.cpp (216765 => 216766)


--- trunk/Source/WebCore/rendering/RenderVideo.cpp	2017-05-12 15:37:17 UTC (rev 216765)
+++ trunk/Source/WebCore/rendering/RenderVideo.cpp	2017-05-12 16:05:38 UTC (rev 216766)
@@ -248,7 +248,7 @@
     
     IntRect videoBounds = videoBox(); 
     mediaPlayer->setSize(IntSize(videoBounds.width(), videoBounds.height()));
-    mediaPlayer->setVisible(true);
+    mediaPlayer->setVisible(!videoElement().elementIsHidden());
     mediaPlayer->setShouldMaintainAspectRatio(style().objectFit() != ObjectFitFill);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to