Add client catch-up mode

Increase worker heartbeats per frame when far behind server to fast-forward simulation.
Track backlog and expose catch-up status via TickMetricsEvent.
Extend performance overlay to display backlog turns and indicate active catch-up mode.
This commit is contained in:
scamiv
2025-11-26 21:35:03 +01:00
parent 7d8c1c2822
commit e31ac7f2cc
3 changed files with 94 additions and 4 deletions
@@ -229,7 +229,12 @@ export class PerformanceOverlay extends LitElement implements Layer {
this.setVisible(this.userSettings.performanceOverlay());
});
this.eventBus.on(TickMetricsEvent, (event: TickMetricsEvent) => {
this.updateTickMetrics(event.tickExecutionDuration, event.tickDelay);
this.updateTickMetrics(
event.tickExecutionDuration,
event.tickDelay,
event.backlogTurns,
event.inCatchUpMode,
);
});
}
@@ -418,7 +423,18 @@ export class PerformanceOverlay extends LitElement implements Layer {
this.layerBreakdown = breakdown;
}
updateTickMetrics(tickExecutionDuration?: number, tickDelay?: number) {
@state()
private backlogTurns: number = 0;
@state()
private inCatchUpMode: boolean = false;
updateTickMetrics(
tickExecutionDuration?: number,
tickDelay?: number,
backlogTurns?: number,
inCatchUpMode?: boolean,
) {
if (!this.isVisible || !this.userSettings.performanceOverlay()) return;
// Update tick execution duration stats
@@ -455,6 +471,13 @@ export class PerformanceOverlay extends LitElement implements Layer {
}
}
if (backlogTurns !== undefined) {
this.backlogTurns = backlogTurns;
}
if (inCatchUpMode !== undefined) {
this.inCatchUpMode = inCatchUpMode;
}
this.requestUpdate();
}
@@ -600,6 +623,11 @@ export class PerformanceOverlay extends LitElement implements Layer {
<span>${this.tickDelayAvg.toFixed(2)}ms</span>
(max: <span>${this.tickDelayMax}ms</span>)
</div>
<div class="performance-line">
Backlog turns:
<span>${this.backlogTurns}</span>
${this.inCatchUpMode ? html`<span> (catch-up)</span>` : html``}
</div>
${this.layerBreakdown.length
? html`<div class="layers-section">
<div class="performance-line">