Title: [247415] trunk/Source/WebCore
- Revision
- 247415
- Author
- [email protected]
- Date
- 2019-07-13 04:07:41 -0700 (Sat, 13 Jul 2019)
Log Message
Fix non thread-safe usage of makeWeakPtr() in MediaPlayerPrivateAVFoundation
https://bugs.webkit.org/show_bug.cgi?id=199777
Reviewed by Eric Carlson.
The code was calling makeWeakPtr() on a main-thread object, from a background thread.
This is not thread safe. To address the issue, this patches creates the WeakPtr ahead
of time, on the main thread.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
(WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification):
(WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (247414 => 247415)
--- trunk/Source/WebCore/ChangeLog 2019-07-13 05:14:00 UTC (rev 247414)
+++ trunk/Source/WebCore/ChangeLog 2019-07-13 11:07:41 UTC (rev 247415)
@@ -1,3 +1,20 @@
+2019-07-13 Chris Dumez <[email protected]>
+
+ Fix non thread-safe usage of makeWeakPtr() in MediaPlayerPrivateAVFoundation
+ https://bugs.webkit.org/show_bug.cgi?id=199777
+
+ Reviewed by Eric Carlson.
+
+ The code was calling makeWeakPtr() on a main-thread object, from a background thread.
+ This is not thread safe. To address the issue, this patches creates the WeakPtr ahead
+ of time, on the main thread.
+
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+ (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
+ (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification):
+ (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+
2019-07-12 Thibault Saunier <[email protected]>
[GStreamer] Mock GStreamer realtime sources should keep a Ref of their mock realtime media sources
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (247414 => 247415)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2019-07-13 05:14:00 UTC (rev 247414)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2019-07-13 11:07:41 UTC (rev 247415)
@@ -55,7 +55,8 @@
namespace WebCore {
MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* player)
- : m_player(player)
+ : m_weakThis(makeWeakPtr(*this))
+ , m_player(player)
, m_queuedNotifications()
, m_queueMutex()
, m_networkState(MediaPlayer::Empty)
@@ -774,7 +775,7 @@
if (delayDispatch && !m_mainThreadCallPending) {
m_mainThreadCallPending = true;
- callOnMainThread([weakThis = makeWeakPtr(*this)] {
+ callOnMainThread([weakThis = m_weakThis] {
if (!weakThis)
return;
@@ -807,7 +808,7 @@
}
if (!m_queuedNotifications.isEmpty() && !m_mainThreadCallPending) {
- callOnMainThread([weakThis = makeWeakPtr(*this)] {
+ callOnMainThread([weakThis = m_weakThis] {
if (!weakThis)
return;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (247414 => 247415)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2019-07-13 05:14:00 UTC (rev 247414)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2019-07-13 11:07:41 UTC (rev 247415)
@@ -327,6 +327,7 @@
const URL& resolvedURL() const { return m_resolvedURL; }
private:
+ WeakPtr<MediaPlayerPrivateAVFoundation> m_weakThis;
MediaPlayer* m_player;
WTF::Function<void()> m_pendingSeek;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes