tips4design

WebGL slower than canvas [FIX]

Recommended Posts

So, I have been working on a game and with Canvas renderer (on mobile, using Cocoon) I had 60FPS, but with WebGl renderer only 20FPS. I started removing things from the game to see what slows the game down (removed the background, disabled the physics, removed the sprites), until the only thing left was the debug text showing FPS: 20. So, the problem was that game.debug.text() is VERY slow on WebGL, and showing any debug text reduces the FPS. I have gone back to 60FPS on WebGl by using bitmapText instead of game.debug.text.

 

Hope this helps someone else who has this issue.

Share this post


Link to post
Share on other sites

It should be generally understood that debugging tools will reduce the performance of your projects, whatever language, platform or framework you're using. The debug tools in Phaser are a case in point - they aren't optimised and don't attempt any clever batching or draw call saving, they just render all of the debug output onto the frame each frame afresh, which in the case of WebGL is particularly inoptimal, though far less so with canvas's 'blitting'. Saying all that, it is worth knowing if you're puzzling over such large performance disparities - I'm surprised this isn't common knowledge though.

Share this post


Link to post
Share on other sites

Well, I thought it was a problem with Cocoon at first, as on PC it works at 60FPS on WebGl while using debug.text, but it might be because of the powerful GPU. I considered that showing the debug text might slow things down, but I didn't think it would slow them that much (from a stable 60FPS to 20FPS only by displaying 6 letters using game.debug.text). I mean, I can display 1000 bitmapText letters and it will still stay at 60FPS, my guess is that something is really bugged in the game.debug.text implementation (eg: something like running a O(N^3) loop when an O(N) loop is possible, or like uploading the texture to the GPU each frame).

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.