test debug logging

This commit is contained in:
scamiv
2025-11-26 15:45:12 +01:00
parent 0fe4a5e004
commit 905e42d34d
6 changed files with 46 additions and 0 deletions
+14
View File
@@ -187,6 +187,13 @@ async function createClientGame(
: undefined;
const usesSharedTileState = !!sharedStateBuffer;
console.log("[ClientGameRunner] SAB flags", {
isIsolated,
canUseSharedBuffers,
hasSharedStateFromMap: !!gameMap.sharedStateBuffer,
usesSharedTileState,
});
if (canUseSharedBuffers) {
// Capacity is number of tile updates that can be queued.
// This is a compromise between memory usage and backlog tolerance.
@@ -697,6 +704,13 @@ export class ClientGameRunner {
drainTime,
};
console.log("[ClientGameRunner] mergeGameUpdates SAB", {
tileCount: tileRefs.length,
utilization,
overflow,
drainTime,
});
for (const ref of tileRefs) {
combinedPackedTileUpdates.push(BigInt(ref));
}
@@ -531,6 +531,13 @@ export class PerformanceOverlay extends LitElement implements Layer {
this.tileUpdatesPerRender = tileUpdatesCount;
this.tileUpdatesPeak = Math.max(this.tileUpdatesPeak, tileUpdatesCount);
this.totalTilesUpdated += tileUpdatesCount;
console.log("[PerformanceOverlay] tile metrics", {
tileUpdatesCount,
ringBufferUtilization,
ringBufferOverflows,
ringDrainTime,
});
}
if (ringBufferUtilization !== undefined) {
+5
View File
@@ -186,6 +186,11 @@ export class GameRunner {
let packedTileUpdates: BigUint64Array;
const tileUpdates = updates[GameUpdateType.Tile];
if (this.tileUpdateSink !== undefined) {
if (tileUpdates.length > 0) {
console.log("[GameRunner] tile updates for tick", this.game.ticks(), {
count: tileUpdates.length,
});
}
for (const u of tileUpdates) {
const tileRef = Number(u.update >> 16n) as TileRef;
this.tileUpdateSink(tileRef);
+6
View File
@@ -496,6 +496,12 @@ export class GameView implements GameMap {
flag: nation.flag,
} satisfies PlayerCosmetics);
}
console.log("[GameView] constructed", {
usesSharedTileState: this.usesSharedTileState,
width: this._map.width(),
height: this._map.height(),
});
}
isOnEdgeOfMap(ref: TileRef): boolean {
+8
View File
@@ -69,6 +69,14 @@ export async function loadTerrainMap(
)
: undefined);
console.log("[TerrainMapLoader] loadTerrainMap", {
map,
mapSize,
canUseSharedBuffers,
hasSharedStateArg: !!sharedStateBuffer,
createdStateBuffer: !!stateBuffer,
});
const gameMap =
mapSize === GameMapSize.Normal
? await genTerrainFromBin(
+6
View File
@@ -78,6 +78,12 @@ ctx.addEventListener("message", async (e: MessageEvent<MainThreadMessage>) => {
sharedTileRing = null;
}
console.log("[Worker.worker] init", {
hasSharedStateBuffer: !!message.sharedStateBuffer,
hasRingHeader: !!message.sharedTileRingHeader,
hasRingData: !!message.sharedTileRingData,
});
gameRunner = createGameRunner(
message.gameStartInfo,
message.clientID,