Discuss Scratch

dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

So, why does the Flash Player not perform well at times? I'm not talking about efficient programming here, which always helps.

I've noticed for me having a more powerful computer seems to help, but other people have stated it runs very smoothly on a weak (hardware-wise) computer and then on a faster computer it will actually lag MORE.

The computer I'm on doesn't run Scratch too well when it comes to intense projects:
Intel Pentium D (Dual-Core) 2.80 GHz
2 GB RAM
Radeon x1950 PRO 256mb
Windows XP Media Center Edition (Service Pack 3)


My other computer seems to run Scratch without a hitch almost:
AMD X4 Quad-Core Processor
Radeon HD 5850 1 GB
4 GB RAM
Windows XP Pro Service Pack 3


Perhaps hardware doesn't make too much of a difference, since Scratch doesn't use hardware-acceleration? But still I feel like both computers are more than capable. I noticed generally Scratch also runs slightly slower as a rule in Google Chrome than it does in Firefox for me at least on both comps.

Last edited by dusty22 (July 1, 2013 13:16:16)

DadOfMrLog
Scratcher
1000+ posts

What causes lag/bad performance in the flash player?

See my lag test project to find out what your setup has trouble with in particular. And I'd suggest you try different browsers. Interestingly, IE suffers least from it, for some reason (never thought I'd end up saying that…)

A lot of the lag issue comes from some kind of problem scratch has dealing with keyboard events - if you have key-repeat on (esp. if set high), then some kind of buffer fill-up/overflow problem brings about serious lag. (It appears that the fairly recent versions of Flash player in Chrome are particularly susceptible to the problem. But Chrome also seems to have problems even from just a single tap, so it's not entirely to do with buffer fill-up…)

But reading through the comments in the lag test project, there also seem to be some issues with mouse-related events for some people.

You will probably find that performance becomes much improved if you switch off key-repeat while playing heavy scratch games.
(Actually switching it off is easy in Mac/Linux, but in Windows is something of a pain - the control panels only allow you to lower the rate. The way to really switch it off is via the easy access settings {IIRC?} - search google to find precise instructions…)

Hope that helps!
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

^Yes, I've seen your project, very useful and well made I must say.

I'll try the key-repeat thing. I did it on my downstairs computer, but scratch already runs pretty well down there, so maybe that was why I didn't notice a difference. I'll also see how IE runs scratch, something I haven't tried yet, except on school computers, which I do remember actually wasn't too bad.
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

DadOfMrLog wrote:

A lot of the lag issue comes from some kind of problem scratch has dealing with keyboard events - if you have key-repeat on (esp. if set high), then some kind of buffer fill-up/overflow problem brings about serious lag. (It appears that the fairly recent versions of Flash player in Chrome are particularly susceptible to the problem. But Chrome also seems to have problems even from just a single tap, so it's not entirely to do with buffer fill-up…)

But reading through the comments in the lag test project, there also seem to be some issues with mouse-related events for some people.

You will probably find that performance becomes much improved if you switch off key-repeat while playing heavy scratch games.
(Actually switching it off is easy in Mac/Linux, but in Windows is something of a pain - the control panels only allow you to lower the rate. The way to really switch it off is via the easy access settings {IIRC?} - search google to find precise instructions…)

Okay, so I dunno about key-repeat. I mean, I turned down the repeat speed in control panel, but it didn't seem to make much of a difference. Maybe if I turn it off completely?

Still I feel like the problem is the Scratch player itself. I mean, it should really have some kind of hardware acceleration. Sometimes I don't get why my dual-core PC with a good gfx card can't run my megaman project (http://scratch.mit.edu/projects/10828380/ ) without steady lag spikes but a psx could run something similar without a hitch.

Last edited by dusty22 (July 5, 2013 16:34:11)

turkey3
Scratcher
1000+ posts

What causes lag/bad performance in the flash player?

Johnm wrote
I believe there may be several different lag problems. One problem that I've been able to reproduce (but not solve yet) seems to be specific to Chrome (or possibly the version of Flash built into Chrome). The symptom is slow/delayed/jerky response to keyboard events, such as you find in many games. But the lag only appears in certain projects and I haven't yet figured out what's special about those projects that causes it. But the projects with this problem run smoothly in all my other browsers (all of which run Flash 10.3.183.86). Did the lag problems you notice involve keyboard input?

I've also seen some bad redisplay problems with certain versions of Safari 5. Fortunately, those bugs were fixed in later versions of Safari, and I don't think many people still run the buggy version of Safari. That bug was so bad that Scratch was totally unusable.

The graphic effects were unusably slow on one model of Samsung Chromebook (the 300 series). For example, color change effect was 20 times slower on that model than it was on the apparently almost identical Samsung 500 series Chromebook. That turned out be be related to the processor on that particular model, which was an ARM-architecture. Many of the graphic effects in Scratch use the Adobe “PixelBender” image processing engine but that engine was never ported to ARM. (This particular problem is unlikely to affect most Scratch 2.0 users.)

Last edited by turkey3 (July 6, 2013 13:59:45)

dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

^Well, for me anyway, the lag isn't so much from keyboard events. In DadofMrLog's lag test project even with key repeat on high the key press events are generally smooth for me.
DadOfMrLog
Scratcher
1000+ posts

What causes lag/bad performance in the flash player?

dusty22 wrote:

^Well, for me anyway, the lag isn't so much from keyboard events. In DadofMrLog's lag test project even with key repeat on high the key press events are generally smooth for me.

Is that the case even in Chrome? And Firefox? (IE seems to not have the same issue, from what people have said.)
What flash player are you using (in each browser)? Are you finding pretty much the same on both of the machines you mentioned?

If you're on XP does it mean your Flash player could be pretty old? -There does seem to be mention of the problem being more to do with recent versions of the Chrome Flash player (called “Pepper”, IIRC?), so maybe if yours is older, that could explain why you do OK?

Do you find other events (like mouse click/drag) are more problematic, then?

Sorry, lots of question…!
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

^I'll post comments on your project.
robomouse
Scratcher
8 posts

What causes lag/bad performance in the flash player?

DadOfMrLog wrote:

Interestingly, IE suffers least from it, for some reason (never thought I'd end up saying that…)

IE lags horribly and can't play sound on my computer which runs Windows 8 :-(
so I guess it depends on your computer.

Flash player may also not have been designed to run things like large scratch programs.
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

robomouse wrote:

Flash player may also not have been designed to run things like large scratch programs.

Whaa? Flash games can be pretty huge I would think. I would personally think games made in Scratch would generally be smaller and less performance-intensive than most bigger Flash games on the internet.

Last edited by dusty22 (July 8, 2013 12:31:26)

turkey3
Scratcher
1000+ posts

What causes lag/bad performance in the flash player?

In this topic, I stated how on some old computers with an older IE, the editor and project page load separately, and that's why some older computers may seem to lag less. The project isn't what lags, but it's the editor. Even when you're on the project page, the editor is still fully loaded and running; it's just hidden, so Scratch lags, in my opinion, because even on the project page the editor is still always open and running. They're on the same Webpage, but there's an old IE glitch I saw where the editor and project page loaded separately, so when I was viewing a project on the project page it was extremely smooth and fast because the editor wasn't open.
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

^Yeah I commented on that in your topic in the Scratch forums (of course the Scratch team has yet to put in their input).

They, or someone knowledgeable about it, said that the editor had to run the way Scratch it coded, but that didn't make sense to me.
dusty22
Scratcher
100+ posts

What causes lag/bad performance in the flash player?

*BUMP*

Alright, so one thing I've noticed, is that because it has no video card / GPU hardware acceleration, Scratch puts all of it's load on your computer's main ram, and the CPU, and maybe the browser too. (I dunno is the browser even much of a factor computing performance?)

On my weaker dual-core Pentium D computer, using task manager, I noticed that for my performance-intensive megaman project the CPU usage would go from 0-10% (that's with me idling on my comp with Scratch open and some background programs) to a steady 50 - 60% with the project actively running with occasional spikes synonomous with lag. The RAM usage would also spike up by about 100 - 200 mb while the project was running.

On this computer (the more powerful one with a quad-core AMD CPU and a very powerful GPU), the processor usage goes from about 0 - 5% (idling on the project page) to about a steady 10 - 15% (sometimes spiking up to 20%), and the RAM usage increases about 10 - 20 mb sometimes getting up to a total increase of about 40 - 50 mb.

Interesting to note though on this comp (I haven't tried it on the weaker one yet), is that according to GPUz, a video card usage monitor, the GPU load/usage never goes past 1% while the Scratch player is running my project.


/ / / / / / / /
I think one reason why Scratch lags is that both all the calculations/information and all the graphics processing is handled by the CPU. Perhaps if the GPU handled some of the visuals, that would free up the processor to do it's job more efficiently.

Last edited by dusty22 (July 18, 2013 13:51:56)

Joy475
Scratcher
5 posts

What causes lag/bad performance in the flash player?

i hope scratch well make a solid update to fix our problems even i have the problem in my mac in sarfira and chrome

Powered by DjangoBB