Bug 1329075 - Avoid an infinite event loop spin. r=jesup

Because we add tracks to the output streams async, it's possible to switch the
mSrcStream of a media element and *then* get a notification of an added track,
when this track originated from the old mSrcStream.
If the new mSrcStream is an output stream of the media element, this would
again add a new track async, which on the next event loop spin would show up
on mSrcStream, and the loop continues.

MozReview-Commit-ID: HmKgXLYmubh
This commit is contained in:
Andreas Pehrson
2017-01-09 19:10:48 +01:00
parent 1e53104c97
commit adf481a046

View File

@@ -3150,6 +3150,12 @@ HTMLMediaElement::AddCaptureMediaTrackToOutputStream(MediaTrack* aTrack,
}
aOutputStream.mCapturingMediaStream = true;
if (aOutputStream.mStream == mSrcStream) {
// Cycle detected. This can happen since tracks are added async.
// We avoid forwarding it to the output here or we'd get into an infloop.
return;
}
MediaStream* outputSource = aOutputStream.mStream->GetInputStream();
if (!outputSource) {
NS_ERROR("No output source stream");