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.19k stars 1.46k forks source link

Extensions cannot be removed if its stage monitor had been shown #2331

Open apple502j opened 4 years ago

apple502j commented 4 years ago

Expected Behavior

Extensions without its blocks should not be serialized, or should be skipped in deserialization.

Actual Behavior

The monitor block for it will be kept during serialization and deserialization, making it impossible to remove without modifying JSON.

Related Code

https://github.com/LLK/scratch-vm/blob/develop/src/serialization/sb3.js#L1168 - Deserialization of monitors; extensions are re-added there.

Steps to Reproduce

Add an extension with a stage monitor (such as Translate), show it then hide it. Save the project locally or on the website, and reload it. The extension is not removed, despite having no translation blocks.

Operating System and Browser

any

Related: #712

towerofnix commented 3 years ago

One place this has come up in the wild for me is this "minimalist categories" platformer project I made (based off of other people's different approaches): https://scratch.mit.edu/projects/413336108/

It's a little misleading for the music extension to show up below the project when I don't actually use any music blocks! :)

I left a note in the Notes and Credits about this...

for some reason scratch still thinks this is using the music extension, but if you see inside youll find there are no blocks

...but I think some people (fairly enough) missed that, if this comment is indicative :P

it shows music extension. =/

This issue definitely doesn't have a major impact. Still, here's some practical motivation for anyone considering writing a fix: leaving the project creator accidentally misleading project viewers ("why does this project have the Music/WeDo/etc extension if it doesn't actually use those?"), with no choice besides to copy-paste all the sprites and code into a totally different project (which nobody would really do, and would separate the project from the remix tree!) is unfortunate!

apple502j commented 3 years ago

@towerofnix Okay gonna write a quick fix