fasterthanlime / jsmad

:saxophone: Javascript MPEG-1 Audio Layer III (mp3) and ID3v2 decoder
http://audiocogs.org/codecs/mp3/
762 stars 41 forks source link

jsmad taking 100+% CPU #18

Open maxart opened 13 years ago

maxart commented 13 years ago

I'm experiencing a pretty heavy CPU usage in Firefox 5 (as in, continuously at 100+% CPU). Is there anything else I could provide to help getting to the bottom of this issue?

Capture: http://cl.ly/2b2p0l3z0E402z2I3f2h

Config: Mac OS X 10.6.7 2.53 GHz Intel Core 2 Duo 4 GB 1067 MHz DDR3 NVIDIA GeForce 9400M, 256 MB Intel® X25-M SSD

Browser: Firefox 5 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0

nddrylliog commented 13 years ago

Firefox/OSX seems to be the worst possible combination for jsmad performance :/ I'm not sure why exactly.

See issue #10 as well: I suspect jsz is on OSX+Firefox as well.

I see that it's an "Intel (64-bit)" process - do you have any way to run a 32-bit version of Firefox 5 just to test? Just curious to see if it makes any difference.

Also: is that using AjaxStream? (ie. listening to an mp3 from official.fm) or using FileStream (local file) ?

Also, when you have time, please install Firebug, click "Profile", play a file, wait a few seconds, and post a screenshot of the profiling results.

We should probably provide a testing page that does only decoding as fast as possible, displays the speed at which it's being decoded and thus is easier to use for profiling. On my todo list as soon as my exams are over :)

nddrylliog commented 13 years ago

Also, you can try it with Chrome 13.0 + Web Audio enabled on the exact same computer+OS, to see if it's a browser-dependant issue or not.

maxart commented 13 years ago

Same conditions, same machine, using Chrome Canary (14.0.798.0 canary): 19.4% CPU average Capture: http://cl.ly/3c2b1C0e3T3c3x2w1m0v

And for some unknown reason, Firefox 5 now refuses to load & play the MP3 file, and throws an error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://assets.jsmad.org/audiolib.js/lib/audiolib.min.js :: <TOP_LEVEL> :: line 1" data: no]

It was loading and playing fine just a moment ago... I'll keep trying, and get that Profile report for you.

maxart commented 13 years ago

Firefox Aurora 6.0a2 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0a2) Gecko/20110619 Firefox/6.0a2) appears to be "better", with an average of 104% CPU. That said, the computer is unusable until I kill Firefox. Profile report: http://cl.ly/283Z3Y1e34423C3h0Z3Q

nddrylliog commented 13 years ago

About that error: weird, I've contacted Jussi (the author of audiolib.js) about it. I supposed you've tried reloading from scratch (Ctrl+Shift+R) and restarting Firefox already :)

Hmm no, the improvement from FF5 to FF6 seems to be accidental, the core issue is still there.

jussi-kalliokoski commented 13 years ago

Are you running it locally or from jsmad.org? If locally, please make sure it's the latest version and if it's any different when using jsmad.org. It would seem that it might be related to that. Fx5 is not working good, but Fx6 should be very nice.

nddrylliog commented 13 years ago

jsmad.org has version 0.4.5, and the github repo still has 0.4.4 I believe.

On Wed, Jun 22, 2011 at 11:19 AM, jussi-kalliokoski < reply@reply.github.com>wrote:

Are you running it locally or from jsmad.org? If locally, please make sure it's the latest version and if it's any different when using jsmad.org. It would seem that it might be related to that. Fx5 is not working good, but Fx6 should be very nice.

Reply to this email directly or view it on GitHub: https://github.com/nddrylliog/jsmad/issues/18#issuecomment-1416838

Amos Wenger Community Development Engineer official.fm - "The Do It Yourself Music Club" I'm @nddrylliog https://github.com/nddrylliog on GitHub

maxart commented 13 years ago

I should have specified, sorry. That was all using jsmad.org, opening/playing a local MP3 file

jussi-kalliokoski commented 13 years ago

Please update audiolib.min.js on jsmad.org, it doesn't currently include the better hack for Fx6+. :)

nddrylliog commented 13 years ago

@maxart: Hey, no problem. It's helping us pinpoint the problem :) Now our remaining suspicions are, I guess, either audiolib.js scheduling or mp3 decoding (I'm betting on the latter!)

@jussi-kalliokoski: Just updated! It's surprisingly smooth at 8-9% CPU in FF6.0a2 (Aurora) even when spamming new tabs (also knows as "the drunk baby test": Let Ctrl+T pressed for 10 secondes)

jussi-kalliokoski commented 13 years ago

Great! I'm afraid there isn't much I can do about Fx5 right now, unless someone comes up with a new hack for it. :/

maxart commented 13 years ago

Thanks guys for the replies and follow ups! I guess it's time to nag at Mozilla?

nddrylliog commented 13 years ago

Yup, I tweeted a few devs to ask for help but no response so far. Maybe filing a bug is a good idea? (Let's hope they respond with more than "It has to be a bug in the mp3 js decoder")

Also, I just read the "Know your engines - Make Javascript Fast" slides and they say "Talk to us!" so... let's talk to them :)

@maxart, do you want to report the Mozilla bug yourself? I can't test since I don't have OSX handy. https://bugzilla.mozilla.org/

On Wed, Jun 22, 2011 at 1:02 PM, maxart < reply@reply.github.com>wrote:

Thanks guys for the replies and follow ups! I guess it's time to nag at Mozilla?

Reply to this email directly or view it on GitHub: https://github.com/nddrylliog/jsmad/issues/18#issuecomment-1417271

Amos Wenger Community Development Engineer official.fm - "The Do It Yourself Music Club" I'm @nddrylliog https://github.com/nddrylliog on GitHub

maxart commented 13 years ago

Done: https://bugzilla.mozilla.org/show_bug.cgi?id=666219 Please feel free to comment on the bugzilla post & add more details!

nddrylliog commented 13 years ago

You might want to add your Firefox 6.0a2 and Chrome 13.0 results, right?

On Wed, Jun 22, 2011 at 1:18 PM, maxart < reply@reply.github.com>wrote:

Done: https://bugzilla.mozilla.org/show_bug.cgi?id=666219 Please feel free to comment on the bugzilla post & add more details!

Reply to this email directly or view it on GitHub: https://github.com/nddrylliog/jsmad/issues/18#issuecomment-1417321

Amos Wenger Community Development Engineer official.fm - "The Do It Yourself Music Club" I'm @nddrylliog https://github.com/nddrylliog on GitHub