Jump to content

Stellar Guardian - HTML5 Bullet Hell Multiplayer (1v1 Duels, Co-op, Achievements)


luca06
 Share

Recommended Posts

Hello everyone,

I'm developing an HTML5 canvas browser game and some users are reporting that the game "freezes" or becomes extremely laggy, especially **when not in fullscreen mode** or after pressing ESC to exit fullscreen. The game works smoothly at 60fps when in fullscreen, but as soon as the player exits fullscreen or the window loses focus, the framerate drops drastically and the gameplay appears frozen or extremely slow.

- The issue happens both on desktop and mobile (various browsers).
- There are no JavaScript errors in the console.
- The main game loop uses `requestAnimationFrame` and limits deltaTime for stability.
- The game resumes running normally if fullscreen is re-activated.

**Is there a way to keep the game running smoothly even when not in fullscreen, or is this a browser limitation?**
Any workaround or best practice to avoid the freeze/lag effect?  
Thanks for any advice!

*Optional: Here is a screenshot of the game for reference.*
 

Screenshot 2025-08-06 122149.png

Link to comment
Share on other sites

Sometimes requestAnimationFrame stops firing or becomes inconsistent. You can detect that and fallback to a timer loop:

let lastTime = performance.now();
let rafId: number;
let fallbackId: number;

function gameLoop() {
  const now = performance.now();
  const delta = Math.min((now - lastTime) / 1000, 0.1); // Clamp deltaTime
  lastTime = now;

  update(delta);
  render();

  rafId = requestAnimationFrame(gameLoop);
}

// Start fallback as a backup
fallbackId = setInterval(() => {
  if (performance.now() - lastTime > 100) {
    // Throttled, call a manual update
    gameLoop();
  }
}, 200);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...