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
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3142,16 +3142,22 @@ HTMLMediaElement::AddCaptureMediaTrackTo
bool aAsyncAddtrack)
{
if (aOutputStream.mCapturingDecoder) {
MOZ_ASSERT(!aOutputStream.mCapturingMediaStream);
return;
}
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");
return;
}
ProcessedMediaStream* processedOutputSource =
outputSource->AsProcessedStream();