Performance issue with graphical programs using long scripts

Issue:
When a long script is called to run, other moving sprites pause for a visually noticeable period of time.

I think this is caused by the IDE adding the glow around a running script.

Demo example - press spacebar - to see effect.

Spacebar script is deliberately VERY long to show the issue easily - you can try numbers 1 - 9 to see shorter, mopre realistic examples

My workaround is to put the script inside a dummy custom block and call it that way instead - press 0 to try that out

Background
This is from my missile command program and it first came to light when I was using when key pressed blocks to launch my missiles and I noticed that the incoming missiles visibly paused

I thought it was to do with detecting keyboard events - so instead of using on key hat blocks - i used a forever loop

and that stopped the glitches (But it turns out that it was the putting my script inside the custom block that removed the glitches and not the keyboard hat block)

Recently, I added the bomber going across the screen after a few seconds, and the glitch came back :frowning:

Then I noticed that if I put my script inside a custom block - the glitches went away

Of course, it might just be on my machine :slight_smile:

If not and its replicable, can the "glow" effect be made more co-operative to other running processes or as a last resort - can it be made a project setting?

I like your custom block solution! If you have a script that's soooo long that just highlighting it induces a noticeable pause that's a sure indicator to create a custom block :wink:

(Naw, no additional settings or "modes")

I've also experienced these lags and always tought it was due to keyboard events detection (as you did) and haven't dig into it. Thank you for the custom block solution.

JFI I've actually stuck with using a forever loop as it stops an unwanted OS keyboard key repeat event effect

image

Not sure I understood what the problem is here. What's wrong with forever loop and key repeat event?

Well its more blocks than 1 hat simple key pressed hat block .

The problem it's solving is to avoid repeating key press events if user holds the key down too long

Ah yes, now understood. That's reasonable.

Will you share the project here on this forum?

Already done

The same problem for rather a short script but many iterations
pause script pic
or even without screen interaction
pause script pic (1)

With non-preemeptive multithreading of Snap!, other scripts are blocked by a long-running one.

That is to be expected once warp is used around long running operations

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.