Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(app): guard runner_ init in run() and drop duplicate startup cache clear

esengine1ed836a6c7b2
diff --git a/sdk/src/app.ts b/sdk/src/app.ts
index d7163a1df..d78881794 100644
--- a/sdk/src/app.ts
+++ b/sdk/src/app.ts
@@ -430,14 +430,16 @@ export class App {
}
this.running_ = true;
- this.runner_ = new SystemRunner(this.world_, this.resources_, this.eventRegistry_);
- if (this.statsEnabled_) {
- this.runner_.setTimingEnabled(true);
+ if (!this.runner_) {
+ this.runner_ = new SystemRunner(this.world_, this.resources_, this.eventRegistry_);
+ if (this.statsEnabled_) {
+ this.runner_.setTimingEnabled(true);
+ }
+ if (!this.resources_.has(Time)) {
+ this.resources_.insert(Time, { delta: 0, elapsed: 0, frameCount: 0 });
+ }
+ this.finishPlugins_();
}
-
- this.resources_.insert(Time, { delta: 0, elapsed: 0, frameCount: 0 });
-
- this.finishPlugins_();
await this.flushStartupSystems_();
this.lastTime_ = platformNow();
@@ -700,7 +702,6 @@ export class App {
if (startup.length === 0) return;
this.flushing_startup_ = true;
try {
- this.sortedSystemsCache_.delete(Schedule.Startup);
await this.runSchedule(Schedule.Startup);
startup.length = 0;
this.sortedSystemsCache_.delete(Schedule.Startup);