Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question webgl powerPreference

Discussion in 'Web' started by roka, Apr 8, 2024.

  1. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    Hello,

    When i check the powerPreference (https://docs.unity3d.com/ScriptReference/WebGLPowerPreference.html), if i understand well :

    Default = 0
    LowPower = 1
    HighPerformance = 2


    https://www.gaming-style.com/share/1.png
    https://www.gaming-style.com/share/4.png

    Loader.js :

    https://www.gaming-style.com/share/3.png

    But when i check the webgl documentation (https://registry.khronos.org/webgl/specs/latest/1.0/#5.2) :

    It's like :

    Default = 0
    HighPerformance = 1
    LowPower = 2

    https://www.gaming-style.com/share/3.png

    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.
     
    Last edited: Apr 8, 2024
  2. chris_simpson

    chris_simpson

    Unity Technologies

    Joined:
    Apr 8, 2022
    Posts:
    1
    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.
     
    unityruba likes this.
  3. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    Thank you for your time and answer.
     
    chris_simpson likes this.