scratchfoundation / scratch-vm

Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0
http://scratchfoundation.github.io/scratch-vm/
BSD 3-Clause "New" or "Revised" License
1.22k stars 1.52k forks source link

Stopping other scripts while asking a question that was overridden with a say bubble should not clear bubble #1848

Open kchadha opened 5 years ago

kchadha commented 5 years ago

Expected Behavior

In Scratch 2.0, say bubbles are treated differently from ask bubbles. Say bubbles do not get cleared when running stop other scripts in this sprite but ask bubbles do.

Actual Behavior

1831 fixes an issue where the ask bubble wasn't getting cleared after stoping other scripts, but this change introduces a subtle issue described below.

If a sprite is currently asking, but then some other code triggers that same sprite to "say" something (e.g. when [space] key pressed > say hello), stopping "other scripts in this sprite" has different behavior in Scratch 2.0 and 3.0. In 2.0, the 'hello' bubble is not cleared. With these changes, in 3.0, the 'hello' bubble is cleared because we are not differentiating between say bubbles and ask bubbles, and technically the sprite was still running the "ask and wait" block when we ran the stop block.

Steps to Reproduce

Compare the following in 2.0 and 3.0

  1. Load this project https://scratch.mit.edu/projects/270619071/ and http://llk.github.io/scratch-gui/develop/#270619071
  2. Press the green flag to run the project
  3. Click on the sprite to change what the speech bubble shows for the sprite
  4. Press the space key to stop "other scripts in that sprite"
  5. Notice that in 2.0, the ask prompt goes away, but the speech bubble saying "Hello!" did not go away. Notice that in 3.0, the ask prompt goes away and the speech bubble saying "Hello!" is also gone.
thisandagain commented 5 years ago

/cc @ktbee

TheLogFather commented 5 years ago

I would question whether the desired option here is making the behaviour completely compatible with Scratch 2...

As I mentioned in https://github.com/LLK/scratch-gui/issues/3932#issuecomment-445558980, I think there's an inconsistency in Scratch 2 in that, while "stop other scripts in sprite" does remove a bubble for an ask block that was still running, it doesn't for a say/think block that was still running (i.e. "say/think for N secs").

Since this behaviour is very rare in projects, it's worth considering whether it could be changed for Scratch 3 to be made more consistent (i.e. so "stop other scripts..." does remove bubble for say/think that was still running).

–Note that I don't see a consistency issue if the bubble came from just a "say/think [something]" block (i.e. without the "... N secs"), since that block was not still running when the script stopped, so "stop other scripts..." isn't stopping that block, and the bubble doesn't need to go away.


Speaking more generally, what could be really great here would be to not just make "stop other scripts..." have specific consequences for specific cases (in this case, removing bubbles), but rather to ensure that it really does what it claims – it actually makes any stopped block act in the same way it would if that block had finished 'naturally' – coded in such a way that these things actually happen 'for free' when the block stops, rather than having to make them happen on a case-by-case basis.

I guess that might involve some fairly major rethink of certain parts of the Scratch code – but I thought it might be worth pointing up that distinction in how to view this, for future consideration.

kchadha commented 5 years ago

It should be noted that this bug will not manifest itself until #1831 is merged (it isn't yet).