mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-29 18:42:11 +00:00
Refactor rendering and metrics emission in ClientGameRunner to ensure updates occur only after all processing is complete.
This commit is contained in:
@@ -511,33 +511,35 @@ export class ClientGameRunner {
|
||||
this.pendingStart = 0;
|
||||
}
|
||||
|
||||
if (batch.length > 0 && lastTick !== undefined) {
|
||||
// Only update view and render when ALL processing is complete
|
||||
if (
|
||||
this.pendingStart >= this.pendingUpdates.length &&
|
||||
batch.length > 0 &&
|
||||
lastTick !== undefined
|
||||
) {
|
||||
const combinedGu = this.mergeGameUpdates(batch);
|
||||
if (combinedGu) {
|
||||
this.gameView.update(combinedGu);
|
||||
}
|
||||
|
||||
// Only emit metrics when ALL processing is complete
|
||||
if (this.pendingStart >= this.pendingUpdates.length) {
|
||||
const ticksPerRender =
|
||||
this.lastRenderedTick === 0
|
||||
? lastTick
|
||||
: lastTick - this.lastRenderedTick;
|
||||
this.lastRenderedTick = lastTick;
|
||||
const ticksPerRender =
|
||||
this.lastRenderedTick === 0
|
||||
? lastTick
|
||||
: lastTick - this.lastRenderedTick;
|
||||
this.lastRenderedTick = lastTick;
|
||||
|
||||
this.renderer.tick();
|
||||
this.eventBus.emit(
|
||||
new TickMetricsEvent(
|
||||
lastTickDuration,
|
||||
this.currentTickDelay,
|
||||
this.backlogTurns,
|
||||
ticksPerRender,
|
||||
),
|
||||
);
|
||||
this.renderer.tick();
|
||||
this.eventBus.emit(
|
||||
new TickMetricsEvent(
|
||||
lastTickDuration,
|
||||
this.currentTickDelay,
|
||||
this.backlogTurns,
|
||||
ticksPerRender,
|
||||
),
|
||||
);
|
||||
|
||||
// Reset tick delay for next measurement
|
||||
this.currentTickDelay = undefined;
|
||||
}
|
||||
// Reset tick delay for next measurement
|
||||
this.currentTickDelay = undefined;
|
||||
}
|
||||
|
||||
if (this.pendingStart < this.pendingUpdates.length) {
|
||||
|
||||
Reference in New Issue
Block a user