Implement worker metrics and debugging events

- Introduced WorkerMetricsEvent and SetWorkerDebugEvent to facilitate communication between the main thread and worker for performance monitoring.
- Enhanced ClientGameRunner to emit worker metrics and handle debug configuration updates.
- Updated PerformanceOverlay to display worker metrics and allow toggling of debug settings.
- Refactored Canvas2DRendererProxy and TerritoryRendererProxy to improve rendering performance and manage render cooldowns.
- Added profiling capabilities in Worker.worker.ts to track event loop lag, simulation delays, and message handling metrics.
This commit is contained in:
scamiv
2026-02-03 23:01:17 +01:00
parent ee90da8e66
commit 45a8e33562
9 changed files with 1373 additions and 419 deletions
+15
View File
@@ -2,6 +2,7 @@ import { EventBus, GameEvent } from "../core/EventBus";
import { UnitType } from "../core/game/Game";
import { UnitView } from "../core/game/GameView";
import { UserSettings } from "../core/game/UserSettings";
import type { WorkerMetricsMessage } from "../core/worker/WorkerMessages";
import { UIState } from "./graphics/UIState";
import { ReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier";
@@ -81,6 +82,20 @@ export class RefreshGraphicsEvent implements GameEvent {}
export class TogglePerformanceOverlayEvent implements GameEvent {}
export class SetWorkerDebugEvent implements GameEvent {
constructor(
public readonly config: {
enabled: boolean;
intervalMs?: number;
includeTrace?: boolean;
},
) {}
}
export class WorkerMetricsEvent implements GameEvent {
constructor(public readonly metrics: WorkerMetricsMessage) {}
}
export class ToggleStructureEvent implements GameEvent {
constructor(public readonly structureTypes: UnitType[] | null) {}
}