   [RANT] Flash using 100% CPU
  Hi all, i'm not really sure if this is specific to a particular topic so i will post it here.For a while now, whenever i play an online Flash game the CPU usage jumps to 100%. It doesn't happen immediately, at first it uses a respectable 40-50% CPU on my 1.7GHz Pentium M laptop. But after a minute or so it jumps to 80-100% and the frame rate drops to little over a few frames per second.I am using Flash Player 10 so it's not like i'm running a really old version. In fact, i have a suspicion that the problem will only get worse as my computer becomes more out-of-date. But just because my laptop can't run the latest 3D graphics doesn't mean that it shouldn't be able to run a simple 2D game, even if it is running within a browser. It seems that the developers are making Flash Player with recent PCs in mind rather than making it fast enough to run on any computer (and mine is not that old).I have googled and found a lot of posts saying that they get 100% CPU usage on Firefox only. But don't blame poor Firefox, it just uses a Flash plug-in. And i also get the same problem on IE and Opera (i don't think i have tried Google Chrome yet though). So it is not the browser but the actual Flash plug-in itself.As a computer programmer i have some insight into how computers work and although i do not know how Flash works i could made some educated guesses as to what might be going on under the covers. Well the only thing i could think of is either the programmer is really stupid and uses a very inefficient algorithm for something, or Flash is doing something really stupid like creating a new image object at a different x,y position every time the image is moved or something.Well apparently that guess is (sadly) pretty correct. A while ago i found this post:Quote:Captain P - [Flash] Efficiently drawing a gridAfter a while, I noticed the game started to slow down. I then did some testing, and it looks like the above function doesn't simply blit some pixels, but it adds a rectangle object that gets redrawn every time it falls in the current redraw region - and drawing it also causes the whole screen to be redrawn. As a result, each time that function is called, a new rectangle is created, and all rects are redrawn, so after a few thousand calls, each call will cause a noticeable slowdown, and that's only getting worse.So i was just wondering if anyone else is having this problem and if anyone has found a way to fix it.thanks   
  Here what I guess,Flash 10 supports GPU acceleration, making CPU intensive effects like spirit rotation and alpha blending performed very fast and cheap.If GPU acceleration is not support on your hardware Flash might fall back to software render mode where those effects require a lot of cpu time.Try installing new drivers for your GPU (even if you have an on-board GPU).[Edited by - Kambiz on April 26, 2009 6:40:09 AM];  I think Flash does use GPU acceleration but unfortunately i do not have a very good graphics card. I have a Toshiba Satellite laptop with a standard (read: crap) Intel graphics card. I don't know much about graphics cards so i am not sure what it supports but i would say that you are right about Flash having to fall back to software render mode.But even with my crappy graphics card, surely i should be able to run a little 2D game without much trouble. Hell, i can even run Doom 3 at a reasonable frame rate if i turn all the settings down to the lowest. I think the problem is that the way Flash (or the programmer) does things is very inefficient.   ;  flash + vista + certain drivers seems to have performance issues, try updating your driversThough I really don't understand why its so hard to make decent vista drivers, what makes a opengl driver for a specific graphics card so different on vista than xp;Quote:Original post by KazeThough I really don't understand why its so hard to make decent vista drivers, what makes a opengl driver for a specific graphics card so different on vista than xpFundamentally, they're similar. Vista introduced a number of new features that makes it "harder", but not impossibly so (such as GPU scheduling). My guess (and this is just a guess of course) is that the manufacturers used the new driver model in Vista as an excuse to rewrite large portions of their drivers (as with any software, over time the codebase has probably become messy and there's bits which nobody knows what it does anymore...).As we all know, rewriting from scratch is a recipie for unstable, buggy software for a number of versions to come - after all, all that wierd stuff that nobody knows what it does anymore is probably workarounds for hardware bugs and issues that nobody knows exists anymore (because the drivers used to cover them up!)But that's just a guess, and not really on-topic here :-)   ;Quote:Original post by Kazeflash + vista + certain drivers seems to have performance issues, try updating your driversAh, i forgot to mention that i am using Windows XP. I use a Vista machine at work but that's obviously not the time to be playing games ([grin]), so i haven't tested how Flash runs on it. Although i doubt i would see any problems on that machine since it's a 3GHz dual core.   ;  Any ideas guys? Do you think updating my drivers would do anything, and would there even be an update for such an old driver (2004)?Keep in mind that the CPU usage jumps after about a minute of game play so it's not like the computer can't handle it at all. It seems like a memory leak or something like what was described in the post i linked to. I would just like to know if it is Flash's fault or the game's programmer, because it happens with almost all games i play (even Flash movies).   ;Quote:Original post by XTAL256...the only thing i could think of is either the programmer is really stupid and uses a very inefficient algorithm for something, or Flash is doing something really stupid like creating a new image object at a different x,y position every time the image is moved or something...Flash is finicky.  I'm a full time Flash programmer and I have to try to eradicate performance issues on a daily basis.  There are a number of things that can cause it to suddenly drop performance; sometimes it's the code, sometimes its the hardware.  It's not that Flash programmers are stupid or that program is inefficient (well,in some ways, it is).  If that were the case, people wouldn't be making rich content and rendering things in 3D with it.The thing you have to remember; just like Windows having to run on a multitude of different specs for machines and not working for everyone 100% of the time, Flash has to do the same for browsers.  There are bound to be hiccups somewhere along the way and undoubtedly someone will have issues playing Flash apps and games.  It's nearly impossible to cater to everyone's configuration.  The majority of Flash games also use vector graphics, which take longer to render even if you set them to render as runtime bitmaps.  This can impact performance if you have several vector objects drawing to the screen at once (especially if you're playing games while Flash ads are running on the same page), but the advantage is that vector graphics make swf files much smaller and easier to distribute.Adobe has been working hard to make Flash perform even better with each release of the Flash player, especially that they are trying to push it for use in developing desktop apps now.  It will only get faster as time goes on.If you really want to know why Flash is the way it is, get down and dirty, grab Flash Develop and the Flex compiler and make a couple of Flash apps :)For the record, I have similar problems on my system at home... 100% CPU usage after a few minutes of playing a game.  The graphics card isn't too old, but the motherboard and processor are almost 6 years old each.  Gonna have to work on getting a new computer that's up to speed.   ;  First of all, thank you esrix for your help. I'm glad someone understands my problem.Quote:The thing you have to remember; just like Windows having to run on a multitude of different specs for machines and not working for everyone 100% of the time, Flash has to do the same for browsers.  There are bound to be hiccups somewhere along the way and undoubtedly someone will have issues playing Flash apps and games.  It's nearly impossible to cater to everyone's configuration.That is true, but i fail to see how i could have such a big problem on a platform, browser and machine that surely must have been tested on. Of course, i don't know the inner workings of Flash so i can't really comment but the specs say it can run on Intel Pentium II 450MHz or higher with at least 128MB of RAM and i have well above that.Quote:Adobe has been working hard to make Flash perform even better with each release of the Flash player, especially that they are trying to push it for use in developing desktop apps now.  It will only get faster as time goes on.Well that's good to hear. I was worried that people (Flash developers and/or programmers who use Flash) are assuming that most people these days use a 3GHz dual core and that it's ok if their games are not optimised because no-one is going to notice. Hopefully my problem is just a bug and it will be fixed in the future.;Quote:Original post by XTAL256That is true, but i fail to see how i could have such a big problem on a platform, browser and machine that surely must have been tested on.Wishful thinking ;) Surely, we all hope that developers would test things thoroughly for every platform configuration.  Otherwise, they'd find bugs like Flash operating properly in Internet Explorer but not in FireFox when you use the "gotoAndStop" command in the constructor of the document class.  I had a FUN time with that bug.   