Jump to content

Very slow CanvasRenderer performance for just 3 sprites


willemmulder
 Share

Recommended Posts

I'm trying to draw 3 'tetris blocks' on the screen, but as you can see, the performance is quite bad. I get around 3 frames per second on my machine.

I created a codepen example to demonstrate the effect.

What I do is create one Base texture (i.e. a tilemap) and then create 3 sprites from that base texture, and adding it to the stage. That should be fast, right?

Is there anything obvious that I'm missing?

Thanks!

Link to comment
Share on other sites

I agree that its very slow that I cant even debug what is happening. 

I had a case at "gameofbombs.com" when region textures made from single big canvas were very slow for canvas2d context, even without pixi.

I suggest to not use canvas2d-generated texture to draw on other canvas2d. I can look at the code more closely later.

SUMMARY: I hate canvas2d problems.

Link to comment
Share on other sites

4 minutes ago, ivan.popelyshev said:

So you suggest using e.g. an actual tilemap (from an image) instead of creating the tilemap from a canvas2d?

I also suggest not to use pixi.JS for canvas-only app. It doesnt have any optimizations there.

I'm actually building an Android app using Cordova, and I hope that most devices will support WebGL. That's where Pixi shines.

However for those that don't support WebGL the Android app should still work using the CanvasRenderer. That includes the Android emulator on my local machine. That's why I'm testing on CanvasRenderer for now.

Link to comment
Share on other sites

It ground to a crawl for me too, and I was able to get a profile on it, and the delay is all in the GPU

At the bottom you have a canvas that is 10000x10000

This is way too big

The maximum texture size I'd recommend is 4096x4096... but in my games I often play it safe with 2048x2048 for the canvas renderer because of the time it can take to upload large textures to the gpu

 

Link to comment
Share on other sites

15 minutes ago, themoonrat said:

The maximum texture size I'd recommend is 4096x4096

That did the trick! Making the texture 4096x4096 makes everything smooth again. Thanks so much!

Out of interest: why would a texture that's only approximately 4x larger make the game so incredibly slow? And why would such a large texture not be a problem for the WebGL renderer?

Link to comment
Share on other sites

I'd take a guess that pixi, via the WebGL renderer, is uploading that texture to the GPU once (it's something the lib has control over)

I'd then take a guess that the canvas renderer is uploading that texture to the GPU every frame. 

But just because WebGL _could_ do it, doesn't mean you should. Take a look at https://webglstats.com/webgl/parameter/MAX_TEXTURE_SIZE - 99.9% of gpus devices out there support 4096x4096 texture size, yet only 29.9% support the next size up, 8192x8192. It probably works on your pc because you have a discrete GPU in it. 

Link to comment
Share on other sites

5 minutes ago, ivan.popelyshev said:

If you want to make a tilemap, I recommend to search through this forum. Every week there's tilemap thread where I explain everything all over again.

What kind of information around tilemaps are you referring to? I think I know how to do it, but if not I'll definitely check the forums for any best practices!

 

1 hour ago, themoonrat said:

I'd take a guess that pixi, via the WebGL renderer, is uploading that texture to the GPU once (it's something the lib has control over)

I'd then take a guess that the canvas renderer is uploading that texture to the GPU every frame. 

But just because WebGL _could_ do it, doesn't mean you should. Take a look at https://webglstats.com/webgl/parameter/MAX_TEXTURE_SIZE - 99.9% of gpus devices out there support 4096x4096 texture size, yet only 29.9% support the next size up, 8192x8192. It probably works on your pc because you have a discrete GPU in it. 

Thanks so much!

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