Senders and receivers should be destroyed on the signaling thread |
||
Issue descriptionChrome holds references to webrtc senders and receivers in RTCRtpSender::RTCRtpSenderInternal and RTCRtpReceiver::RTCRtpReceiverInternal which are destroyed on the main thread*. (* In current code there is a race which makes it possible for it to be destroyed on the signaling thread, but due to holding other resources there are CLs pending which guarantees they are destroyed on the main thread through destructor traits.) I just realized that senders and receivers perform Stop() on destruction. Any webrtc operations need to be executed on the webrtc signaling thread, but there doesn't seem to be any guarantees for this. The destructor traits needs to be updated to free main thread resources on main thread and signaling thread resources on signaling thread. The same will apply for Chrome transceivers and webrtc transceivers.
,
Apr 19 2018
To clarify, the concern is if the RTCRtpSenderInternal/RTCRtpReceiverInternal's reference to the webrtc object was the last reference and thus the destructor of the webrtc object is performed on the main thread instead of the webrtc signaling thread, despite normally all operations for the object are performed on the webrtc signaling thread (either by explicitly doing PostTask or by invoking its methods on a PROXY that does the thread jump for you).
,
Apr 19 2018
The destructors for API objects are proxied to the signaling thread just like all the other methods, so you shouldn't end up with any inconsistency on the WebRTC side. But you will end up with a blocking thread hop if destroying the object from a non-signaling thread, which may not be what you want. See: https://codesearch.chromium.org/chromium/src/third_party/webrtc/api/rtpsenderinterface.h?l=72 https://codesearch.chromium.org/chromium/src/third_party/webrtc/api/proxy.h?l=392
,
Apr 20 2018
Oh cool, thanks! Closing this then :)
,
Apr 20 2018
Making blocking calls main thread -> webrtc signaling thread is OK and happens by all the sync APIs already. Blocking in the other direction though would be deadlock prone. |
||
►
Sign in to add a comment |
||
Comment 1 by hbos@chromium.org
, Apr 19 2018