Closed Bug 2008641 Opened 9 days ago Closed 10 minutes ago

Video with createMediaElementSource becomes permanently sluggish / freezes after switching playbackRate a few times with zero video frame copy

Categories

(Core :: Audio/Video: Playback, defect, P3)

Firefox 134
defect

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox-esr115 --- disabled
firefox-esr140 --- disabled
firefox146 --- disabled
firefox147 --- fix-optional
firefox148 --- fix-optional
firefox149 --- fixed

People

(Reporter: karlt, Assigned: sotaro)

References

(Regression)

Details

(Keywords: nightly-community, regression)

Attachments

(2 files, 1 obsolete file)

Most of the changes for bug 1931328 were backed out to address bug 2006276.

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0

Steps to reproduce:

  1. Download https://download.blender.org/demo/movies/BBB/bbb_sunflower_1080p_30fps_normal.mp4.zip
  2. Open it as a local file through Firefox and start playback
  3. Execute the following code:
ctx = new AudioContext();
v = document.querySelector('video');
src = ctx.createMediaElementSource(v);
src.connect(ctx.destination);

switchesLeft = 20;
intervalId = setInterval(() => {
	v.playbackRate = 8;
 	// v.playbackRate = 8.25; // (a muted speed) also makes the bug appear.

	switchesLeft--;
	if (switchesLeft <= 0) {
		clearInterval(intervalId);
		v.playbackRate = 1;
		console.log('back to normal speed');
		return;
	}

	setTimeout(() => {
		v.playbackRate = 1.25;
	}, 100)
}, 300)

Actual results:

After a few playbackRate changes the video becomes super sluggish (FPS drops to about 0.1).

  • The behavior seems to remain even after we go back to playbackRate = 1.
  • The audio seems to be unaffected and plays normally.
  • Pausing + unpausing the video restores normal FPS.
  • Seeking also restores normal behavior.
  • I tried the same with one YouTube video I was unable to reproduce this.
  • Lower playback rates (below ~6) don't always make this bug appear.
  • The CPU doesn't seem to be overloaded. None of the cores' usage goes above 50%.
  • Sometimes switching playbackRate even once makes this bug show up. But sometimes the normal behavior restores after a while of playing back the video at the rate of 1.

I was able to reproduce this on the following Firefox versions: 134.0a1, 132.0.1, 130.0b9, 128.4.0esr, 107.0.1, 103.0.2, 103.0.
On 92.0b9, 97.0b9, 100.0.2, 101.0.1, 102.9.0esr I was unable to reproduce the bug at all.

So it looks like 103.0 is the first version with this bug.

This bug significantly affects an extension of mine called "Jump Cutter", where switching playback rate is the entire purpose of the extension. See original bug report: https://github.com/WofWca/jumpcutter/issues/186

Expected results:

Video doesn't freeze.
If it's impossible to maintain high FPS on high playbackRate, it at least should go back to normal after the playbackRate restores to normal.

Set release status flags based on info from the regressing bug 1899450

:sotaro, since you are the author of the regressor, bug 1899450, could you take a look?

For more information, please visit BugBot documentation.

Flags: needinfo?(sotaro.ikeda.g)

It seems better to disable zero video frame copy with createMediaElementSource()

Assignee: nobody → sotaro.ikeda.g
Flags: needinfo?(sotaro.ikeda.g)
Assignee: sotaro.ikeda.g → nobody

Going to look into the problem.

Assignee: nobody → sotaro.ikeda.g
See Also: → 1931328
See Also: → 2006276
Attachment #9537104 - Attachment is obsolete: true

From Attachment 9537107 [details] [diff], MediaStream in content process seemed to hold a lot of video frames. And it seemed to cause the hardware decoder to run out of video frames for decoding during zero video frame copy.

Attachment #9537160 - Attachment description: WIP: Bug 2008641 - Disable zero copy when too many video frames are used → Bug 2008641 - Disable zero copy when too many video frames are used
See Also: → 2010497
Pushed by sikeda.birchill@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/df5ccf1d555e https://hg.mozilla.org/integration/autoland/rev/0b33a95ffa0e Disable zero copy when too many video frames are used r=gfx-reviewers,media-playback-reviewers,lsalzman,alwu
Status: NEW → RESOLVED
Closed: 10 minutes ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: