From 6995cde01ff1e65e9e74c9851238d6a70793608a Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Thu, 26 Feb 2026 00:05:57 +0100 Subject: [PATCH] fix(3d-nds): wrong lag detection --- app/components/NDS3D.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/components/NDS3D.vue b/app/components/NDS3D.vue index 85030d4..c2fb190 100644 --- a/app/components/NDS3D.vue +++ b/app/components/NDS3D.vue @@ -200,9 +200,10 @@ watch( const { onRender, onBeforeRender } = useLoop(); const LAG_FPS_THRESHOLD = 40; -const LAG_DURATION_SECS = 1; +const LAG_DURATION_SECS = 5; let lagSeconds = 0; let lagCheckDone = false; +let lastFrameTime = Date.now(); const HINT_SPRITE_SCALE = 2; const HINT_SPRITE_DPR = 4; @@ -345,8 +346,17 @@ useKeyUp(({ ndsButton }) => { }); // lag detection -onBeforeRender(({ delta }) => { +onBeforeRender(() => { if (!lagCheckDone) { + const now = Date.now(); + const delta = (now - lastFrameTime) / 1000; + lastFrameTime = now; + + if (document.hidden || delta > 0.5) { + lagSeconds = 0; + return; + } + const fps = 1 / delta; if (fps < LAG_FPS_THRESHOLD) { lagSeconds += delta;