scratchfoundation / scratch-flash

Open source version of the Scratch 2.0 project editor. This is the basis for the online and offline versions of Scratch found on the website.
https://scratch.mit.edu
GNU General Public License v2.0
1.33k stars 512 forks source link

Fix warp thread bug caused by Flash 30 perf "fix" #1398

Closed cwillisf closed 6 years ago

cwillisf commented 6 years ago

The recent changes made in #1396, intended to fix performance problems on Flash version 30, also introduced a timing problem in Scratch threads running in warp mode. Timekeeping was wrong in such cases, leading to incorrect timer block results (see #1397) and causing minutes-long or even permanent hangs in some projects.

This change resolves #1397 by correcting the timekeeping for warp-mode threads, removes the potential for hangs, and also simplifies the thread iteration count estimation math.

I suggest testing this code against at least these three projects:

CC @TheLogFather

TheLogFather commented 6 years ago

Any chance this could get bumped? –There have been a number of cases of 'random' crashes and issues reported in the forums due to this. Here are a few I noticed, for example: https://scratch.mit.edu/discuss/topic/307677/ https://scratch.mit.edu/discuss/topic/312487/ https://scratch.mit.edu/discuss/topic/305171/ https://scratch.mit.edu/discuss/topic/312269/ https://scratch.mit.edu/discuss/topic/313729/ https://scratch.mit.edu/discuss/topic/313993/ (And there are numerous occasions I've had to explain to someone why many of my speedtest projects are giving zero for their timings, as well as why a few of my projects crash because they try to use the timer to know when to leave non-refresh.)