Home > Back-end >  How does Chromium implement failIfMajorPerformanceCaveat?
How does Chromium implement failIfMajorPerformanceCaveat?

Time:07-08

I'm looking for the general algorithm/checks that Chromium does when you specify failIfMajorPerformanceCaveat to be true when creating a WebGL context on a canvas.

I searched the Chromium source code, but quickly got lost in the sea of results and interfaces. I can get it to fail to create a WebGL context if I specify this flag as true and I have hardware acceleration disabled, so I know hardware acceleration enabled/disabled is part of the calculation - but is there more to it than that?

I only care about Chrome/Chromium on any reasonably modern version.

CodePudding user response:

The only two references I could dig up are in /gpu/command_buffer/service/gles2_cmd_decoder.cc and in /gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc, and both are just basically

if (fail_if_major_perf_caveat && is_swiftshader_for_webgl) {
  // fail
}

where SwiftShader is the software rendering engine used for 3D graphics.

This flag was added back in 2013, with the commit message saying

Currently only fails if using swiftshader.

and quick looking at other issues related to this flag I couldn't find something that would add more feature to it, so I doubt there is anything else hidden.

So this will fail only if the software render is active, which should happen only where HWA is disabled (or unavailable).
Note that at the time of implementation they discussed the possibility to make it smarter and fail only if SwiftShader would actually be slower than the native GL implementation, which isn't always the case. But once again it seems they never got back to it.

  • Related