You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change WebGL powerPreference default to high-performance? #10000
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.
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).
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.
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 (
@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.
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.
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!
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.
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.
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)
Activity
kainino0x commentedon Dec 10, 2019
Another option: emit a warning if neither high-performance nor low-power is set. (i.e.
powerPreferenceisEM_WEBGL_POWER_PREFERENCE_DEFAULT). I'm pretty surelow-poweris always no-worse than DEFAULT if the app is happy with integrated gpus (Ken, check me on this statement).kainino0x commentedon Dec 10, 2019
And hey, congrats on #10000 :P
kenrussell commentedon Dec 11, 2019
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.
juj commentedon Dec 11, 2019
+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.
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-performanceorlow-powerflag, can I afterwards query which type of context I actually got? I do have functionemscripten_webgl_get_context_attributes()that does pull downpowerPreference(emscripten/src/library_html5.js
Line 2601 in 599b402
juj commentedon Dec 11, 2019
(and noooo I was eyeing on grabbing #10000 last night, but we were still one too much away from that!)
kenrussell commentedon Dec 11, 2019
@juj the powerPreference will currently be passed back to the application unchanged -
defaultwon't be lowered tolow-powerorhigh-performance. These are actually requests, and conceivably might not be honored by the user agent.stale commentedon Dec 11, 2020
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.
Nitrillo commentedon Dec 21, 2020
Maybe I'm wrong but using
emscripten_webgl_init_context_attributesto set the power preference doesn't seem to be working with SDL, is any of the other options implemented?thanks!
kainino0x commentedon Dec 21, 2020
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.
stale commentedon Apr 17, 2022
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.
juj commentedon Nov 21, 2026
I think this can be closed. The default for
EmscriptenWebGLContextAttributesisEM_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)