WebGL vs Canvas

Discussion and feedback on Construct 2

Post » Thu Apr 09, 2015 12:20 pm

Just wanted to ask... Apart from shader effects and extra framerate performance, are there any additional advantages to going with WebGL over regular canvas rendering for desktop builds? Memory management is different if I understand right, but what are the implications beyond slower startup times? Does it mean content-heavy games will choke on PC's with little memory for instance?

I'm asking because I'm getting more steady performance out of non-WebGL rendering. No herky jerky situation going on as far as I can tell so I'm thinking I might as well just roll with canvas... Right?
B
34
S
15
G
6
Posts: 509
Reputation: 7,326

Post » Thu Apr 09, 2015 12:35 pm

Yes, the memory management means that you'll better be able to manage VRAM usage.

In the ideal world, there should be no reason at all to ever go with canvas if you aren't forced to.

What herky jerkiness are you seeing? I thought the whole Chrome jank issue was supposed to be fixed, at least at 60fps.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,669

Post » Thu Apr 09, 2015 1:29 pm

It's no big deal. Just a sense of slightly uneven screen updating from time to time that I don't get with webgl turned off. I don't even know if it's down to drivers or the dual-gpu solution in my laptop or just needing a fresh Windows re-install (I keep putting it off :P).

But if it's some kind of driver/hardware/OS issue and canvas turns out to be less vulnerable to that kind of thing then I'd gladly sacrifice the extra speed for predictable performance across PC's. Unless there are other limitations to it that is.
B
34
S
15
G
6
Posts: 509
Reputation: 7,326

Post » Thu Apr 09, 2015 1:39 pm

My old-ish laptop with a 512mb graphics card absolutely hated webgl in chrome. Canvas was and still is always butter smooth.... I'm going to do some big image testing tonight to see if I'm mistaken about that on my new machine.

The label on the webgl tin says it's great. But that's just a selling point and might not reflect reality for everyone.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
69
S
18
G
65
Posts: 2,195
Reputation: 41,465

Post » Thu Apr 09, 2015 2:28 pm

including a game-performance check seems not a bad idea, deciding canvas/webgl, but who wants to bother for fast simple gameplay.. is it actually possible to swith renderer in runtime ?

maybe problems with webgl will surface more, with other engines using it more, and hopefully improve the situation, but i read @sqiddster , there seems not much awareness about it being a big problem on other devsites?

"funny" thing about the jerkiness, i have two screens, refreshrate was 75hz on one of them, not sure why...
has bad jerking, move to the other screen 60hz, butter smooth.. put it on the checklist :)
ImageImage
B
68
S
20
G
7
Posts: 822
Reputation: 9,882

Post » Thu Apr 09, 2015 6:15 pm

"is it actually possible to swith renderer in runtime ? "
No, and it might be due ti the fact that without webGL, every single asset of your game is loaded at every given time, while with webGL only necessary parts are. So If a switch could be done, I would think it would force a complete reload which is not something you want to do mid game (in an option menu maybe, but canvas2d being faster than webgl does not mean fast enough in many cases, still would be nice for user experience to have that option in a graphic setting menu, although with every asset being loaded, the crash risk is real for PC with not enough memory, and even without that, the potential is that it may just load images from the disk, which may be a concern).

All in all, canvas2d is a fallback, nothing else, if there is an issue with webGL, then we either fixing it or working around is a better choice short, mid, and long term wise. Unless the issue is C2 specific, in that case fixing it would do the trick.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
48
S
21
G
18
Posts: 2,114
Reputation: 16,877

Post » Thu Apr 09, 2015 6:49 pm

I noticed this too. All stutter in chrome would disappear when I'd switch WebGL off. My new laptop runs WebGL very smoothly in node-webkit 10.5.
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Fri Apr 10, 2015 9:37 am

Every platform I've ever tested - which is a lot and includes obscure mobile platforms and the like - runs WebGL at least as fast as canvas2d, usually 2-5x faster, and in some cases up to 20x faster (yes, twenty times faster per sprite drawn). WebGL also supports layout-by-layout texture memory management to guarantee maximum memory usage, supports shader effects and has more advanced rendering capabilities that the engine uses in some places for even further optimisation (e.g. the rendering of particle effects is different in WebGL mode). canvas2d exists solely as a fallback for old browsers or blacklisted drivers where WebGL won't run (still ~10% of devices according to webglstats.com). In the long term future, it is likely that the canvas2d renderer will eventually be dropped in favour of WebGL rendering, because it's clearly superior and will simplify the engine code and plugin development if you only need to code for one renderer.

If you think canvas2d is faster then please share some measurements, since I have made a lot of measurements and canvas2d is never faster, unless there's a weird bug that does something like use a software-rendered WebGL but GPU-accelerated canvas2d (which should not happen on any modern browsers because the C2 engine now specifically declines any software-rendered WebGL and falls back to canvas2d). Still there may be room for improvement in WebGL mode and I can always optimise it for a given measurable .capx.
Scirra Founder
B
384
S
227
G
86
Posts: 24,139
Reputation: 190,751

Post » Fri Apr 10, 2015 9:40 am

@Ashley could it be possible that, behind the scenes, some webGL specifics operations could be software calculated on some platforms (not asking if it happens, but if browser vendors could work around specific bugs with that, which could explain the slow while not being blacklisted)?
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
48
S
21
G
18
Posts: 2,114
Reputation: 16,877

Post » Sat Apr 11, 2015 10:50 am

IIRC there is only one performance caveat with WebGL: large constantly changing text objects. WebGL can't render text so it uses an intermediate 2D canvas and copies that to a WebGL texture. Sprite fonts and unchanging text objects are not affected though. There's also the opportunity for third party plugins to do something incredibly slow in WebGL mode only, but that's not an official part of C2. So as long as none of that happens it should always be faster. Like I say, if you don't believe me or on the chance I missed something, I need to see .capx examples.
Scirra Founder
B
384
S
227
G
86
Posts: 24,139
Reputation: 190,751

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests