New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 658245 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
OOO until 2019-01-24
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

Very bad performance w/ setInterval on WebGL with multisampling (antialias: true)

Project Member Reported by deanm@chromium.org, Oct 21 2016

Issue description

Version: Version 53.0.2785.143 (64-bit)
OS: OS X 10.9.5

What steps will reproduce the problem?
(1) open test.html


I'm trying to diagnose a performance problem from what I think is a pretty simple test case.  The same OpenGL calls run fine natively, and profiling didn't really seem to be able to tell me much, so I was hoping someone who knew more about the GPU internals could tell me what might be going on.

Attached is a pretty simple WebGL test that runs very badly for me (MacBook Pro Retina with Intel Iris).  I should note that the identical code runs well natively.

It seems like it's related (or at least made worse) by multisampling, you can flip kAntialiasing, it runs smoothly for me without multisampling.  On my machine GL_SAMPLES is 4 with multisampling on, so it's not a lot of multisampling.

The performance seems to get bad when the shapes overlap, and then gets horrible (<1 fps) when they go outside the viewport.  It's hard to measure what's going on, because it's not reflected in any of the WebGL calls, perhaps it's more something with the compositor, etc?  I put a stats.js on top quickly just to show that from the perspective of JavaScript everything is running quickly, however the page basically comes to a crawl and almost kills my laptop (can't command-tab switch apps, etc).

What's happening is pretty simple, there is just a single VBO drawn with GL_TRIANGLES.  It's 111 vertices / 37 triangles (vec4 per vertex), so it's not very big at all.

It's drawn 30 times in separate passes, changing just one uniform mat4 per pass.  There should be no blending or depth testing.

Timeline doesn't tell me too much, except that the GPU is doing something for 1.4s, it seems to attribute this to uniformMatrix4fv but I think it's probably just that is blocking until the GPU finishes.

I tried looking about about:tracing (some screenshots attached), and again I couldn't really see enough to make sense out of what's going on.  It seems there are a lot of kDrawArray entries (many more than the 30 draw calls).  You can see with the vsync overlay how many frames are being missed : (

The attached code is a little harder to read than I would have liked because it went through a pre-processor, so for example all of the GL constants became integer constants.  Sorry about that, there wasn't an easy way to prevent it.  I know maybe the test example seems a bit silly, but it's more of just a reduced reproduction of a performance problem in a realistic usage.

Thanks,
 
Screen Shot 2016-10-21 at 15.05.04.png
187 KB View Download
Screen Shot 2016-10-21 at 15.11.17.png
283 KB View Download
Screen Shot 2016-10-21 at 15.12.15.png
301 KB View Download
Screen Shot 2016-10-21 at 15.12.52.png
337 KB View Download
vsyncs.png
183 KB View Download
test.html
11.9 KB View Download

Comment 1 by deanm@chromium.org, Oct 21 2016

Cc: sunn...@chromium.org ericrk@chromium.org ccameron@chromium.org
Status: Available (was: Untriaged)
Use requestAnimationFrame, not setInterval, to draw in tests, or otherwise a lot of work that's done will be thrown away without being composited and your fps will be very low.

Didn't we used to have a ratelimiter for WebGL to prevent this from happening? It looks like we've still got one for 2D canvas.

Comment 3 by kbr@chromium.org, Oct 22 2016

Cc: erikc...@chromium.org
erikchen@ added better rate limiting for WebGL recently -- specifically on macOS with Intel GPUs -- but I'm not sure whether it's in Chrome 53 or 54.

Comment 4 by deanm@chromium.org, Oct 22 2016

Summary: Very bad performance w/ setInterval on WebGL with multisampling (antialias: true) (was: Very bad performance on WebGL example with multisampling (antialias: true))
I tried it on Version 56.0.2898.0 canary (64-bit) and it feels like its the same, hard to command-tab, etc.

I understand of course to use raf, I'm just surprised such a simple example that anyway seems like it should be able to run at 60fps is able to back up the GPU process so badly.

Just for my own understanding, maybe could someone expand a little bit?  Unfortunately I think I struggle, probably like many WebGL developers, in mapping my knowledge of GPU programming onto Chrome's multi-process GPU architecture.  I can see as just being a bit like a "dual-core" OpenGL driver, but then it seems like there are extra unique layers there for synchronization/timing, IOSurface, compositing, etc.  This is without even mentioning ANGLE and all of that.  Anyway, it's a bit question, but I'm just trying to roughly understand the components at play here and why this manages to get to almost locking the GPU system-wide.

Is there a better way to see into these things, beyond about:tracing?  With tracing options should I be looking at?  Anyway to get more detail?
The issue is there's no swapbuffers in WebGL. So the browser will read the contents of the page at the rate it feels like it can sustain, which may be much less often than your content tries to draw. If your page always tries to draw at 60fps, that'll starve the compositor and means that the contents may be drawn to the screen much less often than the page draws them.
Components: -Internals>GPU>WebGL
Project Member

Comment 7 by sheriffbot@chromium.org, Jun 21 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 8 by kbr@chromium.org, Jun 21 2018

Owner: kbr@chromium.org
Status: WontFix (was: Untriaged)
With the many browser changes that have been made since this bug was filed, the test is running fine now on a MacBook Air with Intel HD 6000 GPU, macOS 10.13.4, Chrome 69.0.3468.0 (Official Build) canary (64-bit).

The recommendation is still to draw with requestAnimationFrame and not setInterval.

Sign in to add a comment