KhronosGroup / KhronosGroup/WebGL
Improve WebGL's power handling
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 2.9k
- Forks
- 704
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
Use of the WebGL API currently implies use of the high-power discrete GPU on dual-GPU systems. A "preferLowPowerToHighPerformance" context creation attribute was specified some time ago, but it hasn't been widely implemented, nor used by web pages.
After discussion in the working group, the following decisions were made:
-
replace preferLowPowerToHighPerformance with an enumerant:
powerPreference = "low_power", "high_performance", "default" -
getContextCreationAttributes should return the user's powerPreference request unless the system had to override it for some reason.
-
Advertise to WebGL developers that the WEBGL_lose_context is a way to forcibly terminate their context.
-
Advertise to WebGL developers that their context may be lost at any time -- for example, if a tab using WebGL has been in the background for a long time.
The working group notes that it's very difficult to handle this automatically. On macOS, it appears to be possible to dynamically switch between the integrated and discrete GPU for running WebGL content without losing the context ( https://codereview.chromium.org/2627323007/ ). The same is not possible on Windows; it is not possible to seamlessly migrate multisampled renderbuffers between GPUs, for example.
Edge attempted to dynamically switch between the integrated and discrete GPUs based on how much GPU load the WebGL application induced. (Multisampled renderbuffers were resolved to single-sample textures before migration, and other corner cases were handled as well.) The result was flaky; developers could not reliably use either GPU, so the mechanism was removed from Edge. Other browser implementers should learn from this experience.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the WebGL context creation and context-loss behavior described in the issue, then compare the four working-group decisions with the current API specification. Done means the powerPreference values and reported creation attributes are defined consistently, and the context-loss guidance is documented for WebGL developers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- computer-graphics, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100