New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 834787 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2018
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Senders and receivers should be destroyed on the signaling thread

Project Member Reported by hbos@chromium.org, Apr 19 2018

Issue description

Chrome 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.
 

Comment 1 by hbos@chromium.org, Apr 19 2018

Steve, Taylor: Is this correct that senders/receivers/transceivers must be destroyed on the webrtc signaling thread, or does it not matter what thread Stop() is run on when there are no other references to the object?

Modifying internal states wouldn't matter since there are no other references that could try to access them concurrently. My concern is if...
- Stopping a sender/receiver/transceiver invokes other objects methods expected to be run on the signaling thread, or
- A blocking invoke is called to another thread and while waiting the "current thread" executes tasks while waiting (this might be unexpected if enqueued main thread tasks occur during releasing a reference to a sender/recevier/transceiver).

Just want to check what the assumptions are about sender/receiver/transceiver destructors.

Comment 2 by hbos@chromium.org, 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).
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

Comment 4 by hbos@chromium.org, Apr 20 2018

Status: WontFix (was: Assigned)
Oh cool, thanks! Closing this then :)

Comment 5 by hbos@chromium.org, 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