Make sure LibWebRTCMediaEndpoint is always destroyed on the main thread
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 18:55:08 +0000 (18:55 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 18:55:08 +0000 (18:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187702

Reviewed by Youenn Fablet.

Make sure LibWebRTCMediaEndpoint is always constructed and destructed on the main thread since
it has a Timer data member and it would not be safe otherwise. LibWebRTCMediaEndpoint is
ThreadSafeRefCounted and frequently passed to other threads.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h

index 98097e7..e020dce 100644 (file)
@@ -1,3 +1,18 @@
+2018-07-16  Chris Dumez  <cdumez@apple.com>
+
+        Make sure LibWebRTCMediaEndpoint is always destroyed on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=187702
+
+        Reviewed by Youenn Fablet.
+
+        Make sure LibWebRTCMediaEndpoint is always constructed and destructed on the main thread since
+        it has a Timer data member and it would not be safe otherwise. LibWebRTCMediaEndpoint is
+        ThreadSafeRefCounted and frequently passed to other threads.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+
 2018-07-16  Sihui Liu  <sihui_liu@apple.com>
 
         IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
index 64e2bbf..ac97196 100644 (file)
@@ -74,6 +74,7 @@ LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint(LibWebRTCPeerConnectionBackend& p
     , m_logIdentifier(peerConnection.logIdentifier())
 #endif
 {
+    ASSERT(isMainThread());
     ASSERT(client.factory());
 }
 
index 22ae284..297b60c 100644 (file)
@@ -57,7 +57,7 @@ class MediaStreamTrack;
 class RTCSessionDescription;
 
 class LibWebRTCMediaEndpoint
-    : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint>
+    : public ThreadSafeRefCounted<LibWebRTCMediaEndpoint, WTF::DestructionThread::Main>
     , private webrtc::PeerConnectionObserver
     , private webrtc::RTCStatsCollectorCallback
 #if !RELEASE_LOG_DISABLED