diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 2f5c24c0aeb5..f639c98ef44e 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -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");