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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
perf(editor): leaf-subscribe the cursor readouts + export long-task attribution
yhh410d9e0c9122
diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 2cb8308dd..12a6d6106 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -300,7 +300,9 @@ function createWindow() {if (VITE_DEV_SERVER_URL) {win.loadURL(VITE_DEV_SERVER_URL + automation);- if (!shotOut) win.webContents.openDevTools({ mode: 'detach' });+ // SHOT_DEVTOOLS: open DevTools during an automation run — for measuring the+ // overhead DevTools itself adds (its protocol bridge stalls the renderer).+ if (!shotOut || process.env.ESTELLA_SHOT_DEVTOOLS) win.webContents.openDevTools({ mode: 'detach' });} else {// Load over app:// (not file://) so the engine glue + play realm resolve from// a real origin. handleApp serves dist/.diff --git a/desktop/src/engine/PerfMonitor.ts b/desktop/src/engine/PerfMonitor.tsindex b23f0b746..3d3a24062 100644--- a/desktop/src/engine/PerfMonitor.ts+++ b/desktop/src/engine/PerfMonitor.ts@@ -139,6 +139,9 @@ export interface SessionCapture {budgetMs: number;frameCount: number;frames: FrameSample[];+ /** Recent main-thread long tasks (browser attribution) — correlate `start`+ * with frame t0/t1 to name what blocked an uninstrumented hitch. */+ longTasks?: Array<{ start: number; ms: number; name: string }>;}const LONG_FRAME_MS = 24; // missed a 60Hz frame@@ -274,6 +277,7 @@ class PerfMonitorImpl {budgetMs: 1000 / 60,frameCount: frames.length,frames,+ longTasks: this.longTasks.slice(),};}diff --git a/desktop/src/engine/StatsStore.ts b/desktop/src/engine/StatsStore.tsindex 5b9847bce..8a9f20b62 100644--- a/desktop/src/engine/StatsStore.ts+++ b/desktop/src/engine/StatsStore.ts@@ -15,7 +15,6 @@ export interface SelTransform {export interface StatsSnapshot {fps: number;entities: number;- cursor: { x: number; y: number } | null;/** The transform of the single selected entity, or null (0 or >1 selected). */selection: SelTransform | null;}@@ -43,7 +42,10 @@ const selEq = (a: SelTransform | null, b: SelTransform | null): boolean =>// entity count, and the viewport cursor's world position. Updated a few times// a second (not per frame) to avoid churning the status bar.class StatsStoreImpl {- private readonly store = createStore<StatsSnapshot>(() => ({ fps: 0, entities: 0, cursor: null, selection: null }));+ private readonly store = createStore<StatsSnapshot>(() => ({ fps: 0, entities: 0, selection: null }));+ // The cursor updates at pointer-move rate; its own store keeps that churn in+ // a leaf readout instead of re-rendering every slow-stats subscriber.+ private readonly cursorStore = createStore<{ x: number; y: number } | null>(() => null);private running = false;private frames = 0;@@ -78,17 +80,19 @@ class StatsStoreImpl {setCursor(x: number, y: number) {const cx = Math.round(x);const cy = Math.round(y);- const cur = this.store.getState().cursor;+ const cur = this.cursorStore.getState();if (cur && cur.x === cx && cur.y === cy) return;- this.store.setState({ cursor: { x: cx, y: cy } });+ this.cursorStore.setState({ x: cx, y: cy }, true);}clearCursor() {- if (this.store.getState().cursor) this.store.setState({ cursor: null });+ if (this.cursorStore.getState()) this.cursorStore.setState(null, true);}subscribe = (fn: () => void): (() => void) => this.store.subscribe(fn);getSnapshot = (): StatsSnapshot => this.store.getState();+ subscribeCursor = (fn: () => void): (() => void) => this.cursorStore.subscribe(fn);+ getCursor = (): { x: number; y: number } | null => this.cursorStore.getState();}export const StatsStore = new StatsStoreImpl();diff --git a/desktop/src/layout/StatusBar.tsx b/desktop/src/layout/StatusBar.tsxindex ea5f62636..5e24c7018 100644--- a/desktop/src/layout/StatusBar.tsx+++ b/desktop/src/layout/StatusBar.tsx@@ -8,6 +8,13 @@ import { StatsStore } from '@/engine/StatsStore';import { SubsystemIndicator } from './SubsystemIndicator';import { Perf } from '@/components/Perf';+// Leaf subscriber for the pointer-rate cursor readout: only this text node+// re-renders on mouse move, never the footer.+function CursorReadout() {+ const cursor = useSyncExternalStore(StatsStore.subscribeCursor, StatsStore.getCursor);+ return <>{cursor ? `${cursor.x}, ${cursor.y}` : '—'}</>;+}+// Bottom status strip — live engine telemetry (real FPS / entity count / cursor// world position) reads in the mono face. Anchors the Content Drawer.export function StatusBar() {@@ -49,7 +56,7 @@ export function StatusBar() {<span className="sitem mono"><MousePointer2 size={11} strokeWidth={1.85} />- {stats.cursor ? `${stats.cursor.x}, ${stats.cursor.y}` : '—'}+ <CursorReadout /></span><span className="sitem mono"><Gauge size={11} strokeWidth={1.85} /> {stats.fps} fpsdiff --git a/desktop/src/panels/Viewport.tsx b/desktop/src/panels/Viewport.tsxindex 5ccf51fe8..60d769834 100644--- a/desktop/src/panels/Viewport.tsx+++ b/desktop/src/panels/Viewport.tsx@@ -206,10 +206,24 @@ function DdRadio({ on, label, onClick }: { on: boolean; label: string; onClick:);}+// Pointer-rate cursor text as its own leaf: only this node re-renders per+// mouse move; the HUD itself follows the slow (333ms) stats cadence.+function HudCursor() {+ const cursor = useSyncExternalStore(StatsStore.subscribeCursor, StatsStore.getCursor);+ if (!cursor) return null;+ return (+ <>+ <strong>+ {cursor.x}, {cursor.y}+ </strong>{' '}+ ·{' '}+ </>+ );+}+// The corner HUD (perf + coordinates). Owns the StatsStore subscription so the-// high-frequency cursor updates re-render ONLY this leaf — not the whole,-// gizmo-heavy Viewport, which otherwise re-rendered on every mouse-move (visible-// as pan/hover stutter).+// slow stats updates re-render ONLY this leaf — not the whole, gizmo-heavy+// Viewport.function ViewportHud({ ready, selCount, zoomPct, tool }: {ready: boolean;selCount: number;@@ -238,14 +252,7 @@ function ViewportHud({ ready, selCount, zoomPct, tool }: {)}<div className="vp-coord"><div className="ro">- {stats.cursor && (- <>- <strong>- {stats.cursor.x}, {stats.cursor.y}- </strong>{' '}- ·{' '}- </>- )}+ <HudCursor />Sel <strong>{selCount}</strong> · {zoomPct}%</div><div className="hint">{TOOL_HINT[tool]}</div>