Webgl powerPreference

Hello,

When i check the powerPreference (Unity - Scripting API: WebGLPowerPreference), if i understand well :

Default = 0
LowPower = 1
HighPerformance = 2



Loader.js :


But when i check the webgl documentation (WebGL Specification) :

It’s like :

Default = 0
HighPerformance = 1
LowPower = 2


I switch from Unity 2019 to Unity 2023.2 and my CPU is burning for a long time before becoming “almost” (sometine never) like in the Unity 2019, so i was searching and by looking at the powerPreference, the difference between the unity doc and khronos doc interpellated me.

If someone know why the 0,1,2 is different from Unity and Khronos.

Thank you.

Hey roka!

Despite the ordering of the Khronos documentation, I’ve validated that the numeric values we’re using are correct, and result in the correct powerPreference attribute being set. That validation was done by building with the various webGLPowerPreference Unity editor settings, and checking the powerPreference attribute of the WebGL context in a few different browsers. I validated that in the console with the following command, which returns a human-readable string.
canvas.getContext("webgl2").getContextAttributes().powerPreference

If you’re still seeing a big performance regression in newer versions, it would be hugely appreciated if you could put together a reproduction project and submit a bug. We’d be happy to investigate.

1 Like

Thank you for your time and answer.

1 Like