Title: [274778] trunk/Source/WebCore
- Revision
- 274778
- Author
- [email protected]
- Date
- 2021-03-22 12:42:32 -0700 (Mon, 22 Mar 2021)
Log Message
Async Clipboard read prevents WebRTC IOSurfaces from being released
https://bugs.webkit.org/show_bug.cgi?id=223489
<rdar://problem/75601433>
Reviewed by Eric Carlson.
Instead of dispatching a task to main thread, the task refing a MediaSample,
we store the MediaSample in MediaPlayerPrivateMediaStreamAVFObjC on the background thread and
access it on main thread with a lock.
This ensures that we do not keep more than one media sample per MediaPlayerPrivateMediaStreamAVFObjC, even if main thread is blocked.
Make sure to reset the video transformation according hasChangedOrientation even if there is no media sample available anymore.
Covered by existing tests.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274777 => 274778)
--- trunk/Source/WebCore/ChangeLog 2021-03-22 19:37:18 UTC (rev 274777)
+++ trunk/Source/WebCore/ChangeLog 2021-03-22 19:42:32 UTC (rev 274778)
@@ -1,3 +1,22 @@
+2021-03-22 Youenn Fablet <[email protected]>
+
+ Async Clipboard read prevents WebRTC IOSurfaces from being released
+ https://bugs.webkit.org/show_bug.cgi?id=223489
+ <rdar://problem/75601433>
+
+ Reviewed by Eric Carlson.
+
+ Instead of dispatching a task to main thread, the task refing a MediaSample,
+ we store the MediaSample in MediaPlayerPrivateMediaStreamAVFObjC on the background thread and
+ access it on main thread with a lock.
+ This ensures that we do not keep more than one media sample per MediaPlayerPrivateMediaStreamAVFObjC, even if main thread is blocked.
+ Make sure to reset the video transformation according hasChangedOrientation even if there is no media sample available anymore.
+ Covered by existing tests.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample):
+
2021-03-22 Jean-Yves Avenard <[email protected]>
Fix typo introduced in r274586 and revert fix from r274667 to get around compilation error following typo.
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (274777 => 274778)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2021-03-22 19:37:18 UTC (rev 274777)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2021-03-22 19:42:32 UTC (rev 274778)
@@ -262,6 +262,9 @@
RetainPtr<WebRootSampleBufferBoundsChangeListener> m_boundsChangeListener;
+ Lock m_currentVideoSampleLock;
+ RefPtr<MediaSample> m_currentVideoSample;
+
bool m_playing { false };
bool m_muted { false };
bool m_ended { false };
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (274777 => 274778)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2021-03-22 19:37:18 UTC (rev 274777)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2021-03-22 19:42:32 UTC (rev 274778)
@@ -268,12 +268,29 @@
m_sampleBufferDisplayLayer->enqueueSample(sample);
}
-void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample(MediaSample& sample, bool hasChangedOrientation)
+void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSample(MediaSample& sample, bool hasChangedOrientation)
{
if (!isMainThread()) {
- callOnMainThread([weakThis = makeWeakPtr(this), sample = makeRef(sample), hasChangedOrientation]() mutable {
- if (weakThis)
- weakThis->processNewVideoSample(sample.get(), hasChangedOrientation);
+ {
+ auto locker = holdLock(m_currentVideoSampleLock);
+ m_currentVideoSample = &sample;
+ }
+ callOnMainThread([weakThis = makeWeakPtr(this), hasChangedOrientation]() mutable {
+ if (!weakThis)
+ return;
+
+ if (hasChangedOrientation)
+ weakThis->m_videoTransform = { };
+
+ RefPtr<MediaSample> sample;
+ {
+ auto locker = holdLock(weakThis->m_currentVideoSampleLock);
+ sample = WTFMove(weakThis->m_currentVideoSample);
+ }
+ if (!sample)
+ return;
+
+ weakThis->processNewVideoSample(*sample, hasChangedOrientation);
});
return;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes