Skip to content

Commit fa7c5ca

Browse files
Reduce bandwidth for high-latency connections
- JPEG quality 30 -> 20 - Server tick rate 35fps -> 20fps - Mouse flush rate 60Hz -> 20Hz (matched to tick rate) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e24d68a commit fa7c5ca

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

client/doom-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ export default class DoomClient {
169169
}
170170
});
171171

172-
// Flush mouse deltas at 60Hz
172+
// Flush mouse deltas at 20Hz (matched to server tick rate)
173173
this._mouseFlushInterval = setInterval(() => {
174174
if (this._mouseDx !== 0 || this._mouseDy !== 0) {
175175
this._send({ type: 'mouse', dx: this._mouseDx, dy: this._mouseDy });
176176
this._mouseDx = 0;
177177
this._mouseDy = 0;
178178
}
179-
}, 1000 / 60);
179+
}, 1000 / 20);
180180

181181
// Notify app.js of pointer lock changes
182182
document.addEventListener('pointerlockchange', () => {

game_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _compress_frame(self, screen: np.ndarray) -> bytes:
419419
"""Compress RGB screen buffer to JPEG bytes."""
420420
img = Image.fromarray(screen)
421421
buf = io.BytesIO()
422-
img.save(buf, format="JPEG", quality=30)
422+
img.save(buf, format="JPEG", quality=20)
423423
return buf.getvalue()
424424

425425
def _extract_audio(self, state) -> bytes | None:

server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
PORT = 3000 if IS_PRODUCTION else int(os.environ.get("PORT", "3000"))
1515
DIST_DIR = os.path.join(os.path.dirname(__file__), "dist")
1616

17-
TICK_RATE = 1 / 35 # 35 fps (original Doom tic rate)
17+
TICK_RATE = 1 / 20 # 20 fps (reduced for lower bandwidth over high-latency connections)
1818

1919
# Binary message tags (first byte)
2020
TAG_VIDEO = b"\x01"

0 commit comments

Comments
 (0)