Open Bug 682553 Opened 13 years ago Updated 1 year ago
[Windows] Animated GIFs generally eating far too much cpu power
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20100101 Firefox/6.0 Build ID: 20110811165603 Steps to reproduce: I used Firefox 6.0 (OS: Win XP) to show animated GIFs in forums. Actual results: My Power Supply beeped every time I showed one or more animated GIFs exactly in the same rhythm as the Icons do. CPU Load is up to 30 % with one Icon, and much above with more than one Icon. This behavior is highly reproducable, without exception. Iron and Opera needs <2% with one Icon. Irfan View idles with the same downloaded Icon, _no_CPU_Load_is_visible_. It's the same Problem with all my other Machines, only the percentage differs a little. With the same percentage I can play 3D Games of high complexity. Expected results: CPU load should be much lower than 1%. It is a general problem in the source, that wasn't recognized so far. There can't be a good reason for this bug. I have an idea what could be the reason, although I didn't ever review the code: The false implementation of the RAII principle: Resources could be allocated and deallocated erroneously for each animation phase of a single GIF, although they're needed all the time. In this case the whole bunch of code is 1. pushed on the stack 2. OS handles are requested 3. memory is allocated 4. code is executed (this is all that should be repeated) 5. memory deallocated 6. OS handles are freed 7. the function exits 8. the function repeats and repeats and ... (only No. 4 should be repeated) This performance bug very often happens with Oo-Design. Once initialized, there should be only an update, triggered through a timing mechanism. All resources should be allocated and deallocated within the scope of this object, and they should be reused as possible. The bug comes to life when instantiating _and_implicitly_initializing_ an object (of an maybe lower layer) again and again, because it doesn't update itself in the right manner, or it instantiates another object with each update, so constructor and destructor are called again and again ... A simple resource leak could be the reason either: Each animation phase could be falsely a single instance of the object. So there would be endless consumption of memory either. The timing mechanism could be inefficient as well, too many tests, too much focused on precision over efficiency, but this is hypothetic. So, with these three ideas in mind (it could be a combination of all three), you should have a Swiss Army knife to solve your problem. Please read this article thoroughfully again. You could do your best to save the environment by reducing CPU cycles to almost 1...3 % of the actual amount. Thank you very much for your interest and your great work! P.S.: Please excuse my poor (german) english (not so polite sounding, although I did my best).
Does the issue still occur if you start Firefox in Safe Mode? http://support.mozilla.com/en-US/kb/Safe+Mode
You need to log in before you can comment on or make changes to this bug.