audio and video are choppy with 100% cpu during playback

RESOLVED FIXED

Status

()

Core
Audio/Video
RESOLVED FIXED
9 years ago
7 years ago

People

(Reporter: blizzard, Unassigned)

Tracking

Trunk
All
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

1.70 KB, application/zip
Details
(Reporter)

Description

9 years ago
See the URL above and conversation here:

http://identi.ca/conversation/9437690

Appears to play back smoothly on Chromium on Linux.

That site might have something strange going on in the rendering pipeline that's worth looking at.

Tried in both 3.5 and 3.6 nightlies, same result.

Comment 1

9 years ago
Plays fine on 3.5 in Windows. Possibly something to do with the sound issues we've been having. What sound system are you using? Pulse? I'll test on Linux when I'm at my Linux box next.
The main issue here is painting performance; the video is being scaled up from its native size (which is expensive) and we're repainting around 2x more than necessary due to the custom controls.  Playing the video and then switching to another tab is a good way to test whether painting performance is involved.  Digging the video URL out of the page and playing it back in its own tab is another way to test this.  Doing this, I see CPU use about half of what it is when playing the video embedded in the DailyMotion page.

The other issue is that Firefox's CPU is spiking very high for short periods of time during playback (for no more than 3-5 seconds).  I'm not sure what's causing this.  CPU was rising above 100% of one core, so suspect the decoder/playback thread may be doing something strange during this time.

Comment 3

8 years ago
This is not a Linux issue, this hits Windows hard as well. I searched for other related bugs; there are some but I'm still not sure Mozilla is well aware of the performance problems <video> has, they are serious (serious enough for me to always try to serve video in Flash, with <video> as a fallback).

I've seen some justifications such as "we can't take advantage of hardware acceleration" and "we have to composite the video with other stuff", but this is far from justifying the current levels of performance, as you'll see below.

I just did a test against Flash (10 r32). Latest Firefox nightly (Gecko/20090922 Minefield/3.7a1pre). Machine has a Core 2 Duo at 2GHz (T7250) and is running Windows 7 RC. Do note that I see this behavior on several machines and OSes; if anything, it gets worse on older CPUs (specially Pentium 4) - by worse I mean worse in comparison to Flash.

Video was 450x360 pixels in size. The Flash version was encoded in H.264, which is more expensive to decode (not that this matters much, as 90% of the CPU is wasted elsewhere). I checked CPU usage while playback, as well as how much it increased when drawing some stuff over the video (in the case of <video>, the built-in controls; for Flash, some transparent controls comparable in size). For <video>, the video was opened on its own (not inside a web page).

100% CPU usage means both cores used fully. CPU was placed in the highest power state possible all the time (otherwise low CPU usages would get inflated).

zoom_level      <video> <video>+controls Flash Flash+controls
100% (450x360)  12%     16%               8%    9%
111% (500x400)  24%     29%              11%   13%
162% (730x584)  46%*    54%**            18%   20%

* Some frames were dropped
** A lot of frames were dropped

Note that Flash was running in software mode (no hardware acceleration at all). Not that its results are strange: this is the kind of CPU usage I'd expect based on my experience with similar software video pipelines. I can get similar (slightly better) results with standalone players (such as mplayer), even when forcing them to do software color conversion, software scaling, software composition of subtitles, and forcing them to draw to the screen in the slowest possible way (no DirectX/OpenGL, no XV, no overlays, no nothing).

Resize quality was similar in both cases (I didn't check it thoroughly, but it looks like standard bilinear in both cases - definitely not nearest neighborhood).

So yeah, it's slow. A lot. If I had to guess, the worst offender would be the resizer (which is very noticeable too when resizing static images, making full page zoom a but of a hassle performance-wise), but in general everything seems a lot slower than it should.

I understand the specific difficulties that a browser might have, but I'd expect at least the same performance Flash has right now, as I don't see how Flash would have it any easier (if anything, being a plugin would make it slower).

Comment 4

8 years ago
Was the video you were testing with being scaled while playing? Do you have the video you used available so I can test with it?

Comment 5

8 years ago
Created attachment 402247 [details]
Samples

(In reply to comment #4)
> Was the video you were testing with being scaled while playing? Do you have the
> video you used available so I can test with it?

In all 3 cases the same video was used. The video was 450x360, so it wasn't scaled on the first case and it was scaled in the other two cases.

This happens with any video. I'm attaching a simple testcase just in case - it fetches the same video from TinyVid and YouTube. It's not exactly the same test but should be pretty close. Results are more or less the same, for example on a Prescott P4 at 3GHz (no HT):

zoom            <video> Flash 
100% (450x360)  48%     30%
111% (500x400)  76%     42%
162% (730x584)  100%*   56%

* A few frames lost here and there

(This was against an older build of Firefox, so I'd expect it to perform a bit better now)
Duplicate of this bug: 495603
Duplicate of this bug: 499842
Summary: audio and video are choppy with 100% cpu during playback on linux → audio and video are choppy with 100% cpu during playback
Duplicate of this bug: 504821
Duplicate of this bug: 515561

Comment 10

8 years ago
Video is absolutely not working, even with Firefox 3.6.
(I use windows XP, Centrino 1.4 Ghz, Firefox 3.6)

The worst problem is that audio is choppy if the CPU is at 100%. Choppy video is less annoying than choppy audio! The most important thing is to give audio somehow a higher priority (compared to video) so it never skips!
Duplicate of this bug: 552404

Comment 12

8 years ago
I think some commenters here are reporting different issues. The Linux-specific issue is that playing video on sites such as openvideo.dailymotion.com renders Firefox basically unusable, where video takes 100% CPU, but video rendering is too slow to produce much of anything on the screen. I have verified that this problem does not exist (at least, not nearly as severely) on a different machine running OSX.

Judging by the few comments here relating to Windows I would suggest that the issue in those comments is distinct from what is described by the bug reporter.

Comment 13

8 years ago
I was trying to duplicate this but daily motion seems to require downloading the entire video before it allows playing it. I can't press 'Play' to stop the buffering. Chris Blizzard, who can we get in touch with at Daily Motion to look into that?

Comment 14

8 years ago
A surprising observation: when I play a video on openvideo.dailymotion.com, and I hit pause, the CPU is still busied, until I switch to a different tab.

Comment 15

8 years ago
Here's another link with super distorted audio playback: http://www.spreadfirefox.com/5years/en-US/

Comment 16

8 years ago
Significantly, the problem occurs also when playing WebM videos on YouTube's HTML5 demo with today's trunk nightly build.

Comment 17

8 years ago
Bastiaan, which problem? The one described in comment 10, comment 14 or comment 15?

Comment 18

8 years ago
(In reply to comment #17)
> Bastiaan, which problem? The one described in comment 10, comment 14 or comment
> 15?

The problem described in comment 1 (audio and video are choppy with 100% cpu during playback).

Comment 19

8 years ago
Er, that should have been comment 0.

Comment 20

8 years ago
Bastiaan, what OS are you using and what is the architecture and speed of your CPU?

Comment 21

8 years ago
1. Fedora 13.
2. i686, Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz

FWIW, I can "play" the same YouTube page using Chromium fluently (like comment 0), which registers as using approx. 20% of one of the CPU cores per WebM video.

Comment 22

8 years ago
> FWIW, I can "play" the same YouTube page using Chromium fluently (like comment
> 0), which registers as using approx. 20% of one of the CPU cores per WebM
> video.

Which YouTube page specifically? I'd like to test against it since I have a machine with similar specs to yours. What size video too. 360p? Are you trying full screen or non-full screen?

Comment 23

8 years ago
One more thing I just noticed: only video is choppy, not audio. (This contrasts with many commenters who reported choppy audio as well.)

Comment 24

8 years ago
(In reply to comment #22)
> Which YouTube page specifically? I'd like to test against it since I have a
> machine with similar specs to yours. What size video too. 360p? Are you trying
> full screen or non-full screen?

I haven't found a WebM video on YouTube that plays fluently. I'm playing 360p (which seems to be the default) non-full screen.

For example:

http://www.youtube.com/watch?v=4KvOXs1YfwQ
Bastiaan, can you please try the steps in bug 571386 comment 3 and report the results?

Comment 26

8 years ago
Matthew, the video is quite fluent when following said instructions.

Comment 27

8 years ago
Bastiaan, Based on comment 26 it looks like Bug 577843 which has a fix in progress.

Comment 28

8 years ago
Chris, I'm not sure about that, because I'm unable to reproduce the issue on a Mac OSX machine or a Windows machine (both of which are slower than my GNU/Linux machine), and bug 577843 is filed against Windows XP. Mind you, on my GNU/Linux system, (scaled) video rendering is so slow Firefox doesn't have time to respond to user input. I would suspect that sharpening the conversion routines wouldn't cause such a drastic reduction in processing time required to fix the issue on my machine.

Comment 29

8 years ago
If it helps, by the way, I had a similar performance problem with CSS transition effects, but this was fixed by roc's layers work.

Comment 30

7 years ago
I have had this issue playing audio, but only when running from localhost. I am unable to replicate on a remote server.
My test package is here: http://versionindustries.com/remote/FF-AUDIO.zip

When running this locally (http://localhost/FF-AUDIO/) I get the following results:
- on page load, normal CPU usage (10-15%)
- on clicking PLAY, CPU goes up to 80 - 90% (combined usage for both cores) within 2 seconds
- audio occasionally chops to start with, then plays smoothly
- CPU usage remains at a combined figure of 80-90%.
- If the file is in the browser cache, this appears to mitigate the effect.

When running the package on a remote server, the max CPU usage I saw was about 30%, and only for a moment.

Macbook Pro 2.4 Ghz Core 2 Duo, 4GB RAM, Mac OS X 10.6.2, Firefox 3.6.10.

Comment 31

7 years ago
(In reply to comment #27)
> Bastiaan, Based on comment 26 it looks like Bug 577843 which has a fix in
> progress.

It turns out you were right. Today's nightly build (which includes the patch for 577843) fixes this bug for me. Video is played smoothly and audio is uninterrupted.

It should be noted that CPU usage is still high (when compared to MPlayer with X11 rendering, for example), but that is a relatively minor problem.

Thanks!
(In reply to comment #31)
> Today's nightly build (which includes the patch
> for 577843) fixes this bug for me. Video is played smoothly and audio is
> uninterrupted.

Victory then!
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Depends on: 577843
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.