From 85dce88ec283dedbb3f3778e3e7f14ae1ef83a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=AA=E3=82=AD=E8=90=8C?= Date: Mon, 8 Sep 2025 23:11:14 +0200 Subject: [PATCH] fix synchronisation between users --- static/chunk-allocator.js | 2 +- static/index.js | 7 +++++-- static/online-users.js | 12 +++++++++--- static/wall.js | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/static/chunk-allocator.js b/static/chunk-allocator.js index b3e937f..12c60e5 100644 --- a/static/chunk-allocator.js +++ b/static/chunk-allocator.js @@ -300,7 +300,7 @@ export class AtlasAllocator { // Call after download() finishes running to give memory back to the allocator, for reuse in // later pixel transfers. - freeDownloaded(arrayBuffer) { + freeDownload(arrayBuffer) { this.#downloadBufferPool.push(arrayBuffer); } diff --git a/static/index.js b/static/index.js index b31f30d..0e3750a 100644 --- a/static/index.js +++ b/static/index.js @@ -189,7 +189,7 @@ function readUrl(urlString) { } if (wallEvent.kind.event == "interact") { - user.simulate(chunkAllocator, wall, wallEvent.kind.interactions); + user.simulate(chunkAllocator, brushRenderer, wall, wallEvent.kind.interactions); } } }); @@ -281,7 +281,10 @@ function readUrl(urlString) { cursor += edit.data.size; } - session.sendEdit(editRecords, new Blob(dataParts)); + let data = new Blob(dataParts); + + console.log("sending edit data. record count:", editRecords.length, "data blob:", data); + session.sendEdit(editRecords, data); }); canvasRenderer.addEventListener(".viewportUpdate", () => reticleRenderer.render()); diff --git a/static/online-users.js b/static/online-users.js index a23ef53..d73c3c8 100644 --- a/static/online-users.js +++ b/static/online-users.js @@ -42,7 +42,7 @@ export class User { return result; } - simulate(chunkAllocator, wall, interactions) { + simulate(chunkAllocator, brushRenderer, wall, interactions) { console.group("simulate", this.nickname); for (let interaction of interactions) { if (interaction.kind == "setBrush") { @@ -72,10 +72,16 @@ export class User { if (interaction.kind == "scribble" && this.#expectContKind(ContKind.Scribble)) { renderToChunksInArea( chunkAllocator, + brushRenderer, this.getScratchLayer(wall), this.simulation.renderArea, - (pixmap, translationX, translationY) => { - return this.haku.contScribble(pixmap, translationX, translationY); + (brushRenderer, canvas, translationX, translationY) => { + return this.haku.contScribble( + brushRenderer, + canvas, + translationX, + translationY, + ); }, ); console.info("ended simulation"); diff --git a/static/wall.js b/static/wall.js index e6915f8..33da1ed 100644 --- a/static/wall.js +++ b/static/wall.js @@ -82,7 +82,7 @@ export class Layer { downloaded.height, ), ); - chunkAllocator.freeDownloaded(downloaded.data); + chunkAllocator.freeDownload(downloaded.data); let canvas = new OffscreenCanvas(downloaded.width, downloaded.height); let ctx = canvas.getContext("bitmaprenderer"); ctx.transferFromImageBitmap(imageBitmap);