Hot reload: replacing a Script migrates instances and swaps behaviour (#75) #86

Closed
opened 2026-09-06 01:25:29 +00:00 by crowmaki · 0 comments
Owner

Parent

#75

What to build

Hot reload is one call. Loading a Script under a name that is already loaded replaces it. On success the Script's classes replace their predecessors: Schemas are re-registered under the same names through Core's replacement path, existing instances migrate by field name, and the class tables' methods are swapped so the next Update runs the new code. Awake does not re-run on migrated instances. On any failure (compile error, error while defining) the previously loaded version of that Script, and every Schema it defined, stays in force. A Script that stops defining a class it used to define leaves that Schema registered; storage for it is not reclaimed.

Acceptance criteria

  • Loading a changed Script under the same name returns true and the next frame's Update runs the new method body
  • After reload, an instance keeps the value of every field present in both versions, a removed field is dropped, and an added field reads as its default from the new define
  • Awake does not run again on surviving instances; Start does not run again either
  • Component Handles and Object Ids survive the reload; component_is_alive stays true
  • A reload that fails to compile returns false, logs, and the old Update keeps running with instance data untouched
  • A reload that fails while defining its second class leaves both the old classes and Schemas in force
  • A class dropped by the new version leaves its Schema registered and its instances untouched
  • Reload with more than one Scene loaded migrates instances in every Scene

Blocked by

## Parent #75 ## What to build Hot reload is one call. Loading a Script under a name that is already loaded replaces it. On success the Script's classes replace their predecessors: Schemas are re-registered under the same names through Core's replacement path, existing instances migrate by field name, and the class tables' methods are swapped so the next `Update` runs the new code. `Awake` does not re-run on migrated instances. On any failure (compile error, error while defining) the previously loaded version of that Script, and every Schema it defined, stays in force. A Script that stops defining a class it used to define leaves that Schema registered; storage for it is not reclaimed. ## Acceptance criteria - [ ] Loading a changed Script under the same name returns true and the next frame's `Update` runs the new method body - [ ] After reload, an instance keeps the value of every field present in both versions, a removed field is dropped, and an added field reads as its default from the new define - [ ] `Awake` does not run again on surviving instances; `Start` does not run again either - [ ] Component Handles and Object Ids survive the reload; `component_is_alive` stays true - [ ] A reload that fails to compile returns false, logs, and the old `Update` keeps running with instance data untouched - [ ] A reload that fails while defining its second class leaves both the old classes and Schemas in force - [ ] A class dropped by the new version leaves its Schema registered and its instances untouched - [ ] Reload with more than one Scene loaded migrates instances in every Scene ## Blocked by - #77 - #81
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar#86
No description provided.