Closed Bug 655563 Opened 13 years ago Closed 6 years ago

High CPU use during playback when timeBeginPeriod(1) has been called

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: bgdistance, Unassigned)

Details

Attachments

(1 file)

30.50 KB, application/x-ms-dos-executable
Details
User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:6.0a1) Gecko/20110506 Firefox/6.0a1
Build Identifier: 

First close all media players and other browsers if there are.
Go to http://www.youtube.com/html5 join html5 test then go to http://www.youtube.com/watch?v=eWUC5Q0RCAA and open taskmgr to monitor the CPU usage.
Play for a little while then open WMP (or any other media player, didn't try a pure music player though), see how much the CPU usage increases.
The WMP you opened isn't playing anything just staying there, how could it affect CPU usage so much?
Many (even most I think) people would like to play some music while they are surfing, when they begin to watch a online video most likely they will just pause the media player. Imagine how many resources go to waste unknowingly, and they will be under the impression that WebM on Fx is so inefficient(as I was).

Reproducible: Always
I think Windows Media Player alters the OS's timer resolution via timeBeginPeriod (or a similar API), and that my be interacting badly with some behaviour in Firefox's media playback engine.  That this can happen is almost certainly a bug in Firefox.

I don't seem to be able to reproduce this on my Windows 7 x64 machine.  The video I tested used around 3-4% of a CPU during playback with out without WMP open, and with and without WMP playing a video.
Maybe it only happens on XP? Not just WMP, I've also trid KMP and Potplayer.
Actually only openning KMP and Potplayer won't affect it, you have to play and pause, no matter video or just audio.
(In reply to comment #1)
> I think Windows Media Player alters the OS's timer resolution via
> timeBeginPeriod (or a similar API), and that my be interacting badly with
> some behaviour in Firefox's media playback engine.  That this can happen is
> almost certainly a bug in Firefox.
> 
> I don't seem to be able to reproduce this on my Windows 7 x64 machine.  The
> video I tested used around 3-4% of a CPU during playback with out without
> WMP open, and with and without WMP playing a video.
If it's not much a imposition, can you test it on Chrome? the thing is that on my computer chrome has much higher CPU usage than Fx in terms of playing a webm video, and CPU usage doesn't insrease after you open MP.
Iv had a few people test it in a forum (non-English), my preliminary conclusion is that Fx has a WebM playing "bug" that can drasticly decrease CPU usage, but it won't "work" after you open a MP, most sadly it only "works" on XP.
Hopefully someone can find out what it is and "implement" it further.
Maybe it's the way the video renders? overlay on xp and vmr on win7? it wouldn't make such a CPU usage difference(almot tenfold), and I didn't see the quality difference.
I'll test this on XP when I get access to an XP VM.
I can reproduce this in my XP VM.  With my test video, Firefox consumes around 5-10% CPU during playback.  Opening Windows Media Player 11 (and doing nothing else--with no video or audio playing in WMP) causes Firefox's CPU use to increase to 40-50%.
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to comment #7)
> I can reproduce this in my XP VM.  With my test video, Firefox consumes
> around 5-10% CPU during playback.  Opening Windows Media Player 11 (and
> doing nothing else--with no video or audio playing in WMP) causes Firefox's
> CPU use to increase to 40-50%.
Thanks for your confirmation.
I can also reproduce this with a simple program that calls |timeBeginPeriod(1);| and then waits for a key press before calling |timeEndPeriod(1);|, so my guess in comment 1 seems to be correct.

My guess is that the video code is sleeping for very short time periods which would usually end up being rounded (up?) to the nearest 10ms due to the default Win32 timer behaviour.  When the timer resolution is changed with timeBeginPeriod, the code will wake up more frequently and may be performing excessive busy work.
Summary: WebM CPU usage drasticly increases when openning a video player → High CPU use when playing video when timeBeginPeriod(1) has been called
Attached file test program
Summary: High CPU use when playing video when timeBeginPeriod(1) has been called → High CPU use during playback when timeBeginPeriod(1) has been called
Component: Audio/Video → Audio/Video: Playback
Mass closing do to inactivity.
Feel free to re-open if still needed.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: