From d6eb9510fd39f06e68ea9bd93c78fb11be81ac49 Mon Sep 17 00:00:00 2001 From: HF Date: Sat, 18 Mar 2023 11:45:37 +0100 Subject: [PATCH] debug --- src/client.js | 1 + src/core/constants.js | 4 ++-- src/socket/SocketServer.js | 2 ++ src/store/actions/index.js | 1 + src/store/middleware/socketClientHook.js | 2 ++ src/ui/ChunkLoader.js | 4 +++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index d8b903c..6f08c01 100644 --- a/src/client.js +++ b/src/client.js @@ -55,6 +55,7 @@ persistStore(store, {}, () => { // for debugging window.ppStore = store; + window.ppRender = getRenderer; }); (function load() { diff --git a/src/core/constants.js b/src/core/constants.js index 975781e..fed0faf 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -99,5 +99,5 @@ export const APISOCKET_USER_NAME = 'apisocket'; // maximum chunks to subscribe to export const MAX_LOADED_CHUNKS = 2000; -export const MAX_CHUNK_AGE = 300000; -export const GC_INTERVAL = 300000; +export const MAX_CHUNK_AGE = 20000; +export const GC_INTERVAL = 20000; diff --git a/src/socket/SocketServer.js b/src/socket/SocketServer.js index 1e1994f..4f9873c 100644 --- a/src/socket/SocketServer.js +++ b/src/socket/SocketServer.js @@ -637,6 +637,7 @@ class SocketServer { } deleteChunk(chunkid, ws) { + console.log('delete chunk', (chunkid >> 8) & 0x00FF, chunkid & 0x00FF, 'for', ws.user.ip); ws.chunkCnt -= 1; if (!this.CHUNK_CLIENTS.has(chunkid)) return; const clients = this.CHUNK_CLIENTS.get(chunkid); @@ -646,6 +647,7 @@ class SocketServer { deleteAllChunks(ws) { if (!ws.chunkCnt) return; + console.logger('delete all chunks for', ws.user.ip); // eslint-disable-next-line for (const client of this.CHUNK_CLIENTS.values()) { const pos = client.indexOf(ws); diff --git a/src/store/actions/index.js b/src/store/actions/index.js index b360526..72c537c 100644 --- a/src/store/actions/index.js +++ b/src/store/actions/index.js @@ -219,6 +219,7 @@ export function requestBigChunk(center) { } export function removeChunks(chunks) { + console.log('remove chunks'); return { type: 'REMOVE_CHUNKS', chunks, diff --git a/src/store/middleware/socketClientHook.js b/src/store/middleware/socketClientHook.js index d37368e..63a8502 100644 --- a/src/store/middleware/socketClientHook.js +++ b/src/store/middleware/socketClientHook.js @@ -17,7 +17,9 @@ export default (store) => (next) => (action) => { } case 'REMOVE_CHUNKS': { + console.log('do'); const { chunks } = action; + console.log('deregister', chunks.filter((chunk) => chunk.recUpdates).map((chunk) => [chunk.i, chunk.j])); const ids = chunks .filter((chunk) => chunk.recUpdates) .map((chunk) => chunk.id); diff --git a/src/ui/ChunkLoader.js b/src/ui/ChunkLoader.js index 53ee3a8..5355970 100644 --- a/src/ui/ChunkLoader.js +++ b/src/ui/ChunkLoader.js @@ -122,7 +122,9 @@ class ChunkLoader { } } }); - this.bcRemoveChunks(remChunks); + if (remChunks.length) { + this.bcRemoveChunks(remChunks); + } // eslint-disable-next-line no-console,max-len console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`); }