setSinkId() promises do not resolve in the order of function calls, even when `sinkId` parameters differ from the element's `sinkId` attribute
Categories
(Core :: WebRTC: Audio/Video, enhancement)
Tracking
()
People
(Reporter: karlt, Unassigned)
Details
media::Parent::RecvGetPrincipalKey()
creates a separate task queue for each call, so its aResolve
parameters are not necessarily called in the same order as RecvGetPrincipalKey()
calls.
This results in similar behavior for HTMLMediaElement.setSinkId()
.
The specification does not require promises to be resolved in order and even requires them to be out of order when the sinkId
parameter for one call matches the sinkId
attribute.
We could provide more predictable behavior by re-using the same TaskQueue in RecvGetPrincipalKey(). However, the principal key does not usually change between calls, so, alternatively, MediaDevices might cache keys (private or not), but these might need to be cleared at appropriate times such as when clearing site data.
Reporter | ||
Comment 1•2 years ago
|
||
When promises are resolved in the wrong order, the audio output is switched to a device that is not the last requested through setSinkId()
.
Reporter | ||
Comment 2•2 years ago
|
||
This unexpected behavior was observed intermittently in test_setSinkId-stream-source.html of https://phabricator.services.mozilla.com/D198231
[02.599Z] [Child 1537: Main Thread]: D/MozPromise SendGetPrincipalKey creating MozPromise (7f3add6dd580)
[02.599Z] [Child 1537: Main Thread]: D/MozPromise SendGetPrincipalKey UseDirectTaskDispatch MozPromise (7f3add6dd580 created at SendGetPrincipalKey)
[02.599Z] [Child 1537: Main Thread]: D/MozPromise <completion promise> creating MozPromise (7f3adbe11570)
[02.599Z] [Child 1537: Main Thread]: D/MozPromise GetPrincipalKey invoking Then() [this=7f3add6dd580, aThenValue=7f3adc723ab0, isPending=1]
[02.599Z] [Child 1537: Main Thread]: D/MozPromise <completion promise> creating MozPromise (7f3add6dd640)
[02.599Z] [Child 1537: Main Thread]: D/MozPromise AnonymizeDevices invoking Then() [this=7f3adbe11570, aThenValue=7f3add05aac0, isPending=1]
[02.600Z] [Child 1537: Main Thread]: D/MozPromise <chained completion promise> invoking Chain() [this=7f3add6dd640, chainedPromise=7f3adc414c40, isPending=1]
[02.600Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3adc414700]
[02.600Z] [Child 1537: Main Thread]: D/MozPromise ResolveOrRejectRunnable::Run() [this=7f3add03e6a0]
[02.600Z] [Child 1537: Main Thread]: D/MozPromise SendGetPrincipalKey creating MozPromise (7f3adc414700)
[02.600Z] [Child 1537: Main Thread]: D/MozPromise SendGetPrincipalKey UseDirectTaskDispatch MozPromise (7f3adc414700 created at SendGetPrincipalKey)
[02.600Z] [Child 1537: Main Thread]: D/MozPromise <completion promise> creating MozPromise (7f3adbe11710)
[02.600Z] [Child 1537: Main Thread]: D/MozPromise GetPrincipalKey invoking Then() [this=7f3adc414700, aThenValue=7f3adc760b00, isPending=1]
[02.600Z] [Child 1537: Main Thread]: D/MozPromise <completion promise> creating MozPromise (7f3add6dd700)
[02.601Z] [Child 1537: Main Thread]: D/MozPromise AnonymizeDevices invoking Then() [this=7f3adbe11710, aThenValue=7f3add05aba0, isPending=1]
[02.601Z] [Child 1537: Main Thread]: D/MozPromise <chained completion promise> invoking Chain() [this=7f3add6dd700, chainedPromise=7f3add6dd340, isPending=1]
[02.604Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3add61f400]
[02.604Z] [Parent 1345: Main Thread]: D/MozPromise RecvGetPrincipalKey creating MozPromise (7f5dff3c7ae0)
[02.604Z] [Parent 1345: Main Thread]: D/MozPromise RecvGetPrincipalKey invoking Then() [this=7f5dff3c7ae0, aThenValue=7f5dfdb72cf0, isPending=1]
[02.604Z] [Parent 1345: StreamTrans #3]: D/MozPromise operator() creating MozPromise (7f5dff3c7e20)
[02.604Z] [Parent 1345: StreamTrans #3]: D/MozPromise operator() resolving MozPromise (7f5dff3c7e20 created at operator())
[02.604Z] [Parent 1345: StreamTrans #3]: D/MozPromise <Proxy Promise> invoking Chain() [this=7f5dff3c7e20, chainedPromise=7f5dff3c7ae0, isPending=0]
[02.604Z] [Parent 1345: StreamTrans #3]: D/MozPromise <Proxy Promise> TaskPriority MozPromise (7f5dff3c7ae0 created at RecvGetPrincipalKey)
[02.604Z] [Parent 1345: Main Thread]: D/MozPromise RecvGetPrincipalKey creating MozPromise (7f5dff3c8160)
[02.604Z] [Parent 1345: StreamTrans #3]: D/MozPromise <chained promise> resolving MozPromise (7f5dff3c7ae0 created at RecvGetPrincipalKey)
[02.605Z] [Parent 1345: Main Thread]: D/MozPromise RecvGetPrincipalKey invoking Then() [this=7f5dff3c8160, aThenValue=7f5dfdb72d60, isPending=1]
[02.605Z] [Parent 1345: StreamTrans #1]: D/MozPromise operator() creating MozPromise (7f5dff3c7460)
[02.606Z] [Parent 1345: StreamTrans #1]: D/MozPromise operator() resolving MozPromise (7f5dff3c7460 created at operator())
[02.606Z] [Parent 1345: StreamTrans #1]: D/MozPromise <Proxy Promise> invoking Chain() [this=7f5dff3c7460, chainedPromise=7f5dff3c8160, isPending=0]
[02.607Z] [Parent 1345: StreamTrans #1]: D/MozPromise <Proxy Promise> TaskPriority MozPromise (7f5dff3c8160 created at RecvGetPrincipalKey)
[02.607Z] [Parent 1345: StreamTrans #1]: D/MozPromise <chained promise> resolving MozPromise (7f5dff3c8160 created at RecvGetPrincipalKey)
[02.608Z] [Parent 1345: StreamTrans #1]: D/MozPromise Resolving Then() call made from RecvGetPrincipalKey [Runnable=7f5dfe745880, Promise=7f5dff3c8160, ThenValue=7f5dfdb72d60] normal dispatch
[02.608Z] [Parent 1345: StreamTrans #1]: D/MozPromise MozPromise::~MozPromise [this=7f5dff3c7460]
[02.609Z] [Parent 1345: StreamTrans #3]: D/MozPromise Resolving Then() call made from RecvGetPrincipalKey [Runnable=7f5dfe745700, Promise=7f5dff3c7ae0, ThenValue=7f5dfdb72cf0] normal dispatch
[02.610Z] [Parent 1345: StreamTrans #3]: D/MozPromise MozPromise::~MozPromise [this=7f5dff3c7e20]
[02.610Z] [Parent 1345: Main Thread]: D/MozPromise ResolveOrRejectRunnable::Run() [this=7f5dfe745880]
[02.611Z] [Parent 1345: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f5dff3c8160]
[02.611Z] [Child 1537: Main Thread]: D/MozPromise operator() resolving MozPromise (7f3adc414700 created at SendGetPrincipalKey)
[02.612Z] [Child 1537: Main Thread]: D/MozPromise Resolving Then() call made from GetPrincipalKey [Runnable=7f3add03e280, Promise=7f3adc414700, ThenValue=7f3adc760b00] directtask dispatch
[02.612Z] [Child 1537: Main Thread]: D/MozPromise ThenValue::Dispatch dispatch task via direct task queue [this=7f3adc760b00]
[02.613Z] [Parent 1345: Main Thread]: D/MozPromise ResolveOrRejectRunnable::Run() [this=7f5dfe745700]
[02.613Z] [Child 1537: Main Thread]: D/MozPromise ResolveOrRejectRunnable::Run() [this=7f3add03e280]
[02.614Z] [Child 1537: Main Thread]: D/MozPromise operator() creating MozPromise (7f3adbe117e0)
[02.615Z] [Child 1537: Main Thread]: D/MozPromise operator() resolving MozPromise (7f3adbe117e0 created at operator())
[02.615Z] [Child 1537: Main Thread]: D/MozPromise <chained completion promise> invoking Chain() [this=7f3adbe117e0, chainedPromise=7f3adbe11710, isPending=0]
[02.616Z] [Child 1537: Main Thread]: D/MozPromise <chained completion promise> TaskPriority MozPromise (7f3adbe11710 created at <completion promise>)
[02.616Z] [Child 1537: Main Thread]: D/MozPromise <chained promise> resolving MozPromise (7f3adbe11710 created at <completion promise>)
[02.618Z] [Child 1537: Main Thread]: D/MozPromise Resolving Then() call made from AnonymizeDevices [Runnable=7f3add03e6a0, Promise=7f3adbe11710, ThenValue=7f3add05aba0] normal dispatch
[02.618Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3adbe117e0]
[02.618Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3adc414700]
[02.619Z] [Child 1537: Main Thread]: D/MozPromise ResolveOrRejectRunnable::Run() [this=7f3add03e6a0]
[02.619Z] [Parent 1345: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f5dff3c7ae0]
[02.620Z] [Child 1537: Main Thread]: D/MozPromise operator() creating MozPromise (7f3adc414700)
[02.620Z] [Child 1537: Main Thread]: D/MozPromise operator() resolving MozPromise (7f3adc414700 created at operator())
[02.621Z] [Child 1537: Main Thread]: D/MozPromise <chained completion promise> invoking Chain() [this=7f3adc414700, chainedPromise=7f3add6dd700, isPending=0]
[02.621Z] [Child 1537: Main Thread]: D/MozPromise <chained promise> resolving MozPromise (7f3add6dd700 created at <completion promise>)
[02.621Z] [Child 1537: Main Thread]: D/MozPromise <chained promise> resolving MozPromise (7f3add6dd340 created at <completion promise>)
[02.622Z] [Child 1537: Main Thread]: D/MozPromise Resolving Then() call made from GetSinkDevice [Runnable=7f3add03eac0, Promise=7f3add6dd340, ThenValue=7f3add05a9e0] normal dispatch
[02.623Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3add6dd700]
[02.623Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3adc414700]
[02.624Z] [Child 1537: Main Thread]: D/MozPromise MozPromise::~MozPromise [this=7f3adbe11710]
[02.632Z] [Child 1537: Main Thread]: D/MozPromise operator() resolving MozPromise (7f3add6dd580 created at SendGetPrincipalKey)
Description
•