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;