Skip to content

Change WebGL powerPreference default to high-performance? #10000

Closed

Description

@kripken

Browsers are moving to change the default WebGL powerPreference from high-performance to low-power (e.g. coming soon in Chrome 80). In practice this change of default means that some users (with 2 GPUs) might see the lower-end one used, and for something like a game engine that could be noticeably slower.

When creating the WebGL context, perhaps Emscripten should default to high-performance? I'd guess most of our users are running higher-end content. However, I'm not totally happy about such a change either, as browsers are preferring the opposite in general.

Other options:

  • Just document this more.
  • Add a commandline option to make it easier to force high-performance, instead of writing the extra code to call the C API for context creation and set EmscriptenWebGLContextAttributes.powerPreference = EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE.
  • Emit a warning in ASSERTIONS mode if high-performance is not set, but by default that's likely excessive.

Thoughts?

cc @juj @kenrussell @kainino0x

Activity

  1. kainino0x commented on Dec 10, 2019

    @kainino0x
    Collaborator
    • Emit a warning in ASSERTIONS mode if high-performance is not set, but by default that's likely excessive.

    Another option: emit a warning if neither high-performance nor low-power is set. (i.e. powerPreference is EM_WEBGL_POWER_PREFERENCE_DEFAULT). I'm pretty sure low-power is always no-worse than DEFAULT if the app is happy with integrated gpus (Ken, check me on this statement).

  2. kainino0x commented on Dec 10, 2019

    @kainino0x
    Collaborator

    And hey, congrats on #10000 :P

  3. kenrussell commented on Dec 11, 2019

    @kenrussell
    Collaborator

    Many of the graphical Emscripten applications I've seen do draw fairly complex 3D scenes, so a default to high-performance might be warranted.

    An easy way to change the default when invoking the compiler (which would then change the generated JavaScript) would be helpful. Adding command line flags to be able to force either the low-power or high-performance GPU would be good, if that's the direction chosen, to insulate against future changes of Emscripten's default.

    Agree that if the application runs well on an integrated GPU, then explicitly specifying a low-power powerPreference should be no worse than using the default.

  4. juj commented on Dec 11, 2019

    @juj
    Collaborator

    Browsers are moving to change the default WebGL powerPreference from high-performance to low-power (e.g. coming soon in Chrome 80).

    * Just document this more.
    

    +1 for this. I think we should honor the default that browsers take, and solve it via documentation. Not all browsers have the same default.

    * Emit a warning in ASSERTIONS mode if `high-performance` is not set, but by default that's likely excessive.
    

    I think rather, in GL_ASSERTIONS || GL_DEBUG mode, print an affirmative non-warning print "Created a WebGL [low-power|high-performance] context with alpha/depth/stencil/whatever flags one got." to highlight what got created?

    @kainino0x: remind me, if I create a GL context with either unset, or explicitly opted high-performance or low-power flag, can I afterwards query which type of context I actually got? I do have function emscripten_webgl_get_context_attributes() that does pull down powerPreference (

    {{{ makeSetValue('a', C_STRUCTS.EmscriptenWebGLContextAttributes.powerPreference, 'power', 'i32') }}};
    ), but does that get filled by the browser?

  5. juj commented on Dec 11, 2019

    @juj
    Collaborator

    (and noooo I was eyeing on grabbing #10000 last night, but we were still one too much away from that!)

  6. kenrussell commented on Dec 11, 2019

    @kenrussell
    Collaborator

    @juj the powerPreference will currently be passed back to the application unchanged - default won't be lowered to low-power or high-performance. These are actually requests, and conceivably might not be honored by the user agent.

  7. stale commented on Dec 11, 2020

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

  8. Nitrillo commented on Dec 21, 2020

    @Nitrillo
    Contributor

    Maybe I'm wrong but using emscripten_webgl_init_context_attributes to set the power preference doesn't seem to be working with SDL, is any of the other options implemented?
    thanks!

  9. kainino0x commented on Dec 21, 2020

    @kainino0x
    Collaborator

    Most browsers don't actually do anything in response to the powerPreference right now. I think it is obeyed by Chrome on Mac, and possibly Safari, but not others. I might be wrong about the exact status.

  10. stale commented on Apr 17, 2022

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

  11. juj commented on Nov 21, 2026

    @juj
    Collaborator

    I think this can be closed. The default for EmscriptenWebGLContextAttributes is EM_WEBGL_POWER_PREFERENCE_DEFAULT (integer value 0), which defaults to the default of the browser's default. That seems like a good way to go, since users can refer to e.g. MDN or WebGL documentation and prevents creating a "well we do things differently here" middle layer. I'll close this as done.

    (Individual emulation APIs like GLEW,GLFW,SDL may want to do something else, though those APIs have probably been resolving this for a long time now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions