Add breakpoints, pause and step for local preview#8532
Add breakpoints, pause and step for local preview#8532malec-palec wants to merge 4 commits into4ian:masterfrom
Conversation
|
Thanks for opening this PR. Looks super useful. We'll take a look asap |
4ian
left a comment
There was a problem hiding this comment.
Quick questions:
- Is this working with custom objects (prefab) events? You can add breakpoints in them and see them being stopped on/stepped in?
- For Trigger Once, I see there is some complex logic related to them, notably skipping the clearing of "_lastFrameOnceTrigger". Is this because breakpoints will stop events and don't guarantee the code generated for events of a scene/custom object won't run until the end?
Yes. Breakpoints, pause and step all work inside custom-object methods (events of an events-based object). The matrix of what gets breakpoint instrumentation is set in
Two extra notes for custom objects specifically:
Behaviors were intentionally left out: their lifecycle methods (
You're right that the trigger is "events don't reach their natural end every frame", but the mechanism is a bit more specific than that. I pause via V8's native The problem appears with stepping, which inherently crosses frame boundaries. Each
Concrete repro (any condition + Flow without the fix:
Fix is a one-shot flag on preserveLastFrameOnNextCycle(): void {
this._preserveLastFrameOnNextCycle = true;
}
// The next startNewFrame() skips the clearing of _lastFrameOnceTrigger,
// then resets the flag.Set in two places, both debugger-only:
Scope is intentionally narrow: only the scene-level |
Add breakpoints, pause and step for local preview
Adds debugging support directly inside the EventsSheet: users can set breakpoints on events, pause/resume the running preview, step through events one at a time, and inspect variable values at the paused point.
Works in local Electron preview only. Web and remote preview show a "use local preview" notification when the user tries to pause/step.
Shortcuts
F9F10Shift+F10All three are also available in the EventsSheet toolbar and the Command Palette.
User flows
Set a breakpoint in a scene
F9. A red dot appears next to the event.F10to resume.Set a breakpoint in an extension function
F9.Breakpoints inside behavior methods are not supported - by design.
Set multiple breakpoints
Breakpoints can live in different event sheets at the same time (multiple scenes, multiple extension functions). All of them are sent to the preview as one payload every time the set changes. Session state is kept in-memory for the lifetime of the editor process - it survives tab close/reopen, but is not persisted across editor restarts or preview relaunches.
Step through events
From a paused state:
Shift+F10- step to the next event (sibling, sub-event, or next event after the current function returns).F10- resume until the next breakpoint (or forever if none).While running:
F10- pause at the start of the next frame, on the first event of the running scene's events sheet. Useful when you have no breakpoints set and just want to drop into the debugger to inspect the current state.Inspect variable values while paused
When the preview is paused:
objectvarparameter kind, e.g. the second parameter ofModify a variable of an object).Paused toast
The "Paused in debugger" toast can be dragged to a custom position. Its position is kept for every subsequent pause in the same preview session. It resets when the preview window is closed or the sheet is unmounted.
Implementation details
For the full architecture, runtime internals, code-generation rules, IDE wiring, and Electron-main CDP flow, see
BREAKPOINTS.mdin the root of the repo.BREAKPOINTS.mdis working documentation for this branch only and will be deleted before merge.