Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:02:27+00:00 2026-06-01T00:02:27+00:00

On my application, I have a canvas which CSS size (CSS, not html) updates

  • 0

On my application, I have a canvas which CSS size (CSS, not html) updates depending on the window size.

I have a main gameplayLoop which looks like this :

run = function(){

    console.log(timerDiff(frameTime));

    game.inputManage();
    game.logics();
    game.graphics.animate();
    game.graphics.render();

    frameTime = timerInit();

    requestAnimFrame(run);

}

My requestAnimFrame function is the one from Paul Irish :

window.requestAnimFrame = (function(){
  return  window.requestAnimationFrame       || 
          window.webkitRequestAnimationFrame || 
          window.mozRequestAnimationFrame    || 
          window.oRequestAnimationFrame      || 
          window.msRequestAnimationFrame     || 
          function( callback ){
            window.setTimeout(callback, 1000 / 60);
          };
})();

So basically the problem is that the timer that I log which measures the time between the requestAnimFrame call and the effective function call totally changes.
If my browser is in fullscreen I get like 50/60 ms, and if I have a small window I can get to something like 10 ms.

As the requestAnimFrame call is supposed to call constantly the function under a 60fps rythm (which is something like 30 ms I think) I shouldn’t have this kind of result, since there is basically nothing happening between the timer’s creation and its check, except the requestAnimFrame

I also have some recurring micro-freezes (less than a second) which happens like every 2/3 seconds. But the timer doesn’t detect any change in the time (like even the time counter of javascript is blocked)

My timers functions are like this but it doesn’t really matter here

timerInit = function()
{
    return new Date();
}

timerDiff = function(datePrev)
{
    return new Date().getTime() - datePrev.getTime();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:02:29+00:00Added an answer on June 1, 2026 at 12:02 am

    Well, the standard basically says that requestAnimationFrame will “do its best” to run at a “consistent” frame rate. That doesn’t guarantee a 60fps; it just states that it will animate as fast as it can.

    My experience with it has been as dim as yours so far unfortunately. I ended up going back to setTimeout. It goes at about the same rate, and graphical updates are accurate and don’t skip a beat as they did with requestAnimationFrame. Sure it wasn’t 60fps, but at least you could tell what was going on.

    I’m sure the performance will only improve as browser developers optimize the new function, but for the time being, consider going back to timeouts.

    Edit: I would like to remind people that this was answered a year ago, and the times have changed 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom canvas in an application, which is not showing image, in
In my WPF application I have a Canvas in which I do some drawing.
I have a Canvas in a Flex application which has items inside it that
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have a scroll viewer in my application that contains a canvas, in which
As part of an application, I have a canvas object <Canvas Name=canvas/> into which
I have an application which uses the canvas to draw the scribbling done by
I have a WPF application in which I'm moving data around on a Canvas.
I have a flex 3 application that creates an Image from a canvas which
We have a custom canvas which has specialized nodes that behave a lot like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.