Title: [289412] branches/safari-613-branch/Source/WebCore
- Revision
- 289412
- Author
- [email protected]
- Date
- 2022-02-08 11:55:26 -0800 (Tue, 08 Feb 2022)
Log Message
Cherry-pick r288435. rdar://problem/83668578
MediaStream canvas.captureStream() playback to LocalSampleBufferDisplayLayer is flaky
https://bugs.webkit.org/show_bug.cgi?id=230623
<rdar://problem/83668578>
Reviewed by Kimmo Kinnunen.
There are a few issues when creating the video element, setting the srcObject and playing it right away.
The first thing is that we try to render the video element while thinking that it might be video accelerated
(it is always the case for MediaStreamTrack based tracks), but the video element is asynchronously updating whether it is accelerated.
Following what other MediaPlayerPrivate are doing, when MediaPlayerPrivateMediaStreamAVFObjC has set up its video layers,
we schedule a call to renderingModeChanged which will trigger a relayout.
We also ensure, when the layer is fully initialized to set all values (bounds, hide states) as otherwise, this might be lost on GPUProcess
which currently does not register a RemoteSampleBufferDisplayLayer at the time the corresponding IPC message is received.
The additional issue is in the case the MediaStreamTrack source only generates one frame for some time.
In that case, and if the frame is enqueueud while setting up the video layers, we were not rendering this frame.
To fix this, when the video layers are ready, we reenqueue the last video frame as neeeded.
Manually tested.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (289411 => 289412)
--- branches/safari-613-branch/Source/WebCore/ChangeLog 2022-02-08 19:51:31 UTC (rev 289411)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog 2022-02-08 19:55:26 UTC (rev 289412)
@@ -1,3 +1,59 @@
+2022-02-08 Russell Epstein <[email protected]>
+
+ Cherry-pick r288435. rdar://problem/83668578
+
+ MediaStream canvas.captureStream() playback to LocalSampleBufferDisplayLayer is flaky
+ https://bugs.webkit.org/show_bug.cgi?id=230623
+ <rdar://problem/83668578>
+
+ Reviewed by Kimmo Kinnunen.
+
+ There are a few issues when creating the video element, setting the srcObject and playing it right away.
+ The first thing is that we try to render the video element while thinking that it might be video accelerated
+ (it is always the case for MediaStreamTrack based tracks), but the video element is asynchronously updating whether it is accelerated.
+ Following what other MediaPlayerPrivate are doing, when MediaPlayerPrivateMediaStreamAVFObjC has set up its video layers,
+ we schedule a call to renderingModeChanged which will trigger a relayout.
+
+ We also ensure, when the layer is fully initialized to set all values (bounds, hide states) as otherwise, this might be lost on GPUProcess
+ which currently does not register a RemoteSampleBufferDisplayLayer at the time the corresponding IPC message is received.
+
+ The additional issue is in the case the MediaStreamTrack source only generates one frame for some time.
+ In that case, and if the frame is enqueueud while setting up the video layers, we were not rendering this frame.
+ To fix this, when the video layers are ready, we reenqueue the last video frame as neeeded.
+
+ Manually tested.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-01-24 Youenn Fablet <[email protected]>
+
+ MediaStream canvas.captureStream() playback to LocalSampleBufferDisplayLayer is flaky
+ https://bugs.webkit.org/show_bug.cgi?id=230623
+ <rdar://problem/83668578>
+
+ Reviewed by Kimmo Kinnunen.
+
+ There are a few issues when creating the video element, setting the srcObject and playing it right away.
+ The first thing is that we try to render the video element while thinking that it might be video accelerated
+ (it is always the case for MediaStreamTrack based tracks), but the video element is asynchronously updating whether it is accelerated.
+ Following what other MediaPlayerPrivate are doing, when MediaPlayerPrivateMediaStreamAVFObjC has set up its video layers,
+ we schedule a call to renderingModeChanged which will trigger a relayout.
+
+ We also ensure, when the layer is fully initialized to set all values (bounds, hide states) as otherwise, this might be lost on GPUProcess
+ which currently does not register a RemoteSampleBufferDisplayLayer at the time the corresponding IPC message is received.
+
+ The additional issue is in the case the MediaStreamTrack source only generates one frame for some time.
+ In that case, and if the frame is enqueueud while setting up the video layers, we were not rendering this frame.
+ To fix this, when the video layers are ready, we reenqueue the last video frame as neeeded.
+
+ Manually tested.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+
2022-02-07 Russell Epstein <[email protected]>
Cherry-pick r289108. rdar://problem/88599722
Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (289411 => 289412)
--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2022-02-08 19:51:31 UTC (rev 289411)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2022-02-08 19:55:26 UTC (rev 289412)
@@ -138,6 +138,7 @@
void processNewVideoSample(MediaSample&, bool hasChangedOrientation, VideoSampleMetadata, Seconds);
void enqueueVideoSample(MediaSample&);
+ void reenqueueCurrentVideoSampleIfNeeded();
void requestNotificationWhenReadyForVideoData();
void paint(GraphicsContext&, const FloatRect&) override;
@@ -168,6 +169,7 @@
void updateTracks();
void updateRenderingMode();
+ void scheduleRenderingModeChanged();
void checkSelectedVideoTrack();
void updateDisplayLayer();
Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (289411 => 289412)
--- branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2022-02-08 19:51:31 UTC (rev 289411)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2022-02-08 19:55:26 UTC (rev 289412)
@@ -277,6 +277,18 @@
m_sampleBufferDisplayLayer->enqueueSample(sample);
}
+void MediaPlayerPrivateMediaStreamAVFObjC::reenqueueCurrentVideoSampleIfNeeded()
+{
+ if (!m_currentVideoSampleLock.tryLock())
+ return;
+ Locker locker { AdoptLock, m_currentVideoSampleLock };
+
+ if (!m_currentVideoSample && !m_imagePainter.mediaSample)
+ return;
+
+ enqueueVideoSample(m_currentVideoSample ? *m_currentVideoSample : *m_imagePainter.mediaSample);
+}
+
void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample(MediaSample& sample, bool hasChangedOrientation, VideoSampleMetadata metadata, Seconds presentationTime)
{
if (!isMainThread()) {
@@ -404,7 +416,10 @@
return;
}
- updateRenderingMode();
+ scheduleRenderingModeChanged();
+
+ m_sampleBufferDisplayLayer->updateBoundsAndPosition(m_sampleBufferDisplayLayer->rootLayer().bounds, m_videoRotation);
+ m_sampleBufferDisplayLayer->updateDisplayMode(m_displayMode < PausedImage, hideRootLayer());
m_shouldUpdateDisplayLayer = true;
m_videoLayerManager->setVideoLayer(m_sampleBufferDisplayLayer->rootLayer(), size);
@@ -422,7 +437,7 @@
if (m_sampleBufferDisplayLayer)
m_sampleBufferDisplayLayer = nullptr;
- updateRenderingMode();
+ scheduleRenderingModeChanged();
m_videoLayerManager->didDestroyVideoLayer();
}
@@ -557,6 +572,7 @@
if (m_sampleBufferDisplayLayer)
m_sampleBufferDisplayLayer->play();
updateDisplayMode();
+ reenqueueCurrentVideoSampleIfNeeded();
scheduleDeferredTask([this] {
updateReadyState();
@@ -628,6 +644,7 @@
m_isPageVisible = isVisible;
flushRenderers();
+ reenqueueCurrentVideoSampleIfNeeded();
}
void MediaPlayerPrivateMediaStreamAVFObjC::setVisibleForCanvas(bool)
@@ -717,15 +734,18 @@
void MediaPlayerPrivateMediaStreamAVFObjC::updateRenderingMode()
{
- if (!updateDisplayMode())
- return;
+ if (updateDisplayMode())
+ scheduleRenderingModeChanged();
+}
+void MediaPlayerPrivateMediaStreamAVFObjC::scheduleRenderingModeChanged()
+{
scheduleDeferredTask([this] {
m_videoTransform = { };
if (m_player)
m_player->renderingModeChanged();
+ reenqueueCurrentVideoSampleIfNeeded();
});
-
}
void MediaPlayerPrivateMediaStreamAVFObjC::characteristicsChanged()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes