Skip to content

fix(preview): pause game loop before first frame for IDE cold-start step - #916

Merged
wuzhiming merged 1 commit into
cocos:mainfrom
DecviL:preview-cold-start-pause
Sep 5, 2026
Merged

fix(preview): pause game loop before first frame for IDE cold-start step#916
wuzhiming merged 1 commit into
cocos:mainfrom
DecviL:preview-cold-start-pause

Conversation

@DecviL

@DecviL DecviL commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Companion to SUD-GLOBAL/PinK#1419 (Preview In Editor cold-start Step).

Problem

PinK's Preview In Editor cold-start Step passes { paused: true, stepOnce: true }, but the pause was only applied after view:ready, which fires after inspect assembly and the loading-overlay hide animation. game-boot.js calls cc.game.resume() in the scene-run callback, so the game advances many frames before the IDE pauses it (source-level repro: ~36 frames on the 600ms fallback path).

Change

  • game-boot.js: when window.__pinkStartPaused is set (injected by the IDE host before the boot chain), pause director + game immediately after cc.game.resume(), i.e. before the first game-loop frame; wrapped in try/catch so engine state anomalies cannot break startup.
  • Regression test: structural invariant pinning pause-after-resume (director + game pause, try/catch converged) in game-boot-scene-load.test.ts.

Validation

  • npx jest src/core/preview/test/game-boot-scene-load.test.ts: 6/6 passing.
  • npx tsc -b: clean.

game-boot now pauses director and game immediately after cc.game.resume() when window.__pinkStartPaused is set, so IDE-driven cold-start Step (PinK Preview In Editor) does not advance frames before its explicit single step; add a structural regression test pinning the pause-after-resume invariant.
@wuzhiming
wuzhiming merged commit 043356a into cocos:main Sep 5, 2026
4 checks passed
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.

2 participants