Skip to content

Fix VM crashes, dropped event arguments and other bugs found while typing the VM - #39

Merged
Mistium merged 8 commits into
developfrom
vm-bug-fixes
Nov 1, 2026
Merged

Mistium merged 8 commits into
developfrom
vm-bug-fixes

Conversation

@Mistium

@Mistium Mistium commented Nov 1, 2026

Copy link
Copy Markdown
Member

Stacked on #37. Found while writing exact TypeScript declarations for the VM (MistWarp/types#1). Each fix comes with a test that fails without it.

  • Crashes: shareSoundToTarget resolves when there is no target, postSpriteInfo returns early with no target, and handleExtensionButtonPress skips a missing callback.
  • startHats no longer upper-cases its caller's match-fields object in place, and accepts match values that aren't strings.
  • Forwarded events keep their arguments: ASSET_PROGRESS passes its detail, EXTENSION_FIELD_ADDED its one object (it used to arrive as (object, undefined)), and PERIPHERAL_REQUEST_ERROR its data. The GUI listeners in loader.jsx and connection-modal.jsx either read the extra arguments or ignore them.
  • Turbo mode is now set through runtime.setTurboMode, so runtime listeners hear it, as with frame rate and interpolation. The VM still emits once per change.
  • runtime.projectName was read by the GUI and the Rotur extension but never set. vm.setProjectName(name) now sets it, defaulting to ''. The GUI needs to call it when the title changes; that follow-up is coming.
  • renameSprite points block references at the deduplicated name.
  • setStageSize no longer moves monitors that have no position yet.
  • getBlocksJSON leaves out entries without JSON.

Checks:

  • Lint, the conventions check and unit tap pass, and snapshots are byte-identical.
  • Parity is identical to develop (2127/2143), and performance is at develop's level.
  • An independent review reverted fixes to confirm the tests fail without them, and checked every GUI listener. It found nothing to fix.

There is no visible change.

shareSoundToTarget read target.sprite before checking that the target
exists, postSpriteInfo called the target before its null check, and
handleExtensionButtonPress called a callback that may not be registered.
startHats upper-cased the caller's match field object, so a caller that
reused it saw its values change, and it threw when a value was not a
string, such as a number broadcast from compiled code.
…ERIPHERAL_REQUEST_ERROR

The VM dropped the asset progress detail and the peripheral error data,
and re-emitted the single extension field object as two arguments, the
second always undefined.
vm.setTurboMode emitted TURBO_MODE_ON and TURBO_MODE_OFF only on the VM,
so runtime listeners missed them. Runtime.setTurboMode now owns the
change like setFramerate and setInterpolation, and the VM forwards it.
The Rotur extension and the GUI read runtime.projectName, but nothing
set it. The title lives in the GUI rather than in project.json, so the
GUI now passes it in with vm.setProjectName.
…rite

When the requested name was taken, the sprite got a numbered name but
blocks that referred to it were updated to the requested name, which is
another sprite's.
A monitor with no position is placed by the GUI when it first shows.
setStageSize added the offset to its null x and y, which pinned it to
the offset itself.
Toolbox entries without a block definition put undefined into the list,
which every caller had to skip. The toolbox fixture loses those nulls,
and the wrong return type JSDoc is gone.
@Mistium
Mistium changed the base branch from vm-structure to develop November 1, 2026 06:48
@Mistium
Mistium merged commit 5b1e85d into develop Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant