Jump to content

Myths and realities of canvas / JavaScript performance


rafinskipg
 Share

Recommended Posts

At fast glance it looks good to me.

 

@chg

The point isn't really to increase FPS. Point is, you design your game based on 30FPS updates, because you suspect older devices will work around that fast + you don't need more FPS. But you can't really control fps with requestAnimationFrame, so what you do is interpolate, to make it look smooth.

All this is based on assumption that rendering takes a lot more time than logic updates, which usually is the case. There shouldn't really be any unevenness because if logic update takes too much, you won't be able to render more frames anyway and it will stay locked at 30FPS, even lower if needed.

Link to comment
Share on other sites

  • 9 months later...

Hi everybody,

 

I saw your topic and i didn't read all replies, i'm not event a game dev but im actually a it engineer and im using canvas to code a new software to make video specialised in app advertisement. I'm actually using canvas as calque in Photoshop, i have about 7 and effectivelly canvas and its context make it slow as hell ! Why? Because the context of the canvas doesnt have any memory manager (garbage collector) ! How to fix it? Make all your canvas and context null when you don't need it into you js file but remove all your canvas from your DOM too.

 

I know you are coding games so you may never delete your canvas because you always need it.

 

I hope i was still useful, sorry for my bad english

 

cheers from France

Link to comment
Share on other sites

  • 3 weeks later...

I know that save() and restore() are very expensive.

 

Can anyone comment on the optimization strategies for calling save and restore efficiently if you have to transform or rotate many sprites each frame? 

Instead of using save and restore, you can save the values and reverse them. so if you rotate the canvas 45 degrees just rotate it -45 degrees when you are done with the animation frame.

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...