[Public WebGL] Use powerPreference to request high or low power GPUs

Kai Ninomiya [email protected]
Mon Jul 2 12:27:16 PDT 2018


I think at one point we talked about having getContextAttributes() return
only 'high-performance' or 'low-power' (never 'default'), but I don't think
this got discussed much or specced.

On Mon, Jul 2, 2018 at 9:00 AM Rachid El Guerrab <
[email protected]> wrote:

> I second Gregg Tavares's question about what's reported back.
>
> How can we tell if we're running with the high-performance option or not?
>
> On Thu, Jun 28, 2018 at 7:36 PM Jeff Gilbert <[email protected]> wrote:
>
>>
>> I don't know about precisely specifying "default" yet, but I do intend
>> to implement the background-tab => iGPU behavior. (that sounds great!)
>>
>> I think there's other ideas worth investigating for "default":
>> - shelving a context's dGPU request if it goes idle/stops drawing.
>> - Only bringing up the dGPU once drawing begins initially. (probes
>> wouldn't spin up the dGPU)
>>
>> I also like the cross-origin idea.
>>
>>
>> On Thu, Jun 28, 2018 at 7:14 PM, Ken Russell <[email protected]> wrote:
>> > On Thu, Jun 28, 2018 at 6:44 PM Dean Jackson <[email protected]> wrote:
>> >>
>> >>
>> >>
>> >> On 29 Jun 2018, at 11:40, Ken Russell <[email protected]> wrote:
>> >>
>> >> It would be helpful to leave the user agent's defaults loosely
>> specified,
>> >> at least for the moment. I'd like to experiment with heuristics to try
>> to
>> >> decide a good default for various kinds of content up front.
>> >>
>> >>
>> >> How would this work? You'd decide per site? Size of the canvas? iframe
>> v
>> >> main page?
>> >>
>> >> We considered many of these things but decided it was better to be
>> >> consistent.
>> >
>> >
>> > Not sure yet; that's why I'd like to experiment. Haven't had the time
>> to do
>> > so yet. cross-origin iframe vs. main page seems like one that may have a
>> > good benefit.
>> >
>> > -Ken
>> >
>> >
>> >> Dean
>> >>
>> >>
>> >>
>> >>
>> >> On Thu, Jun 28, 2018 at 6:20 PM Dean Jackson <[email protected]> wrote:
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> > On 29 Jun 2018, at 07:49, Jeff Gilbert <[email protected]>
>> wrote:
>> >>> >
>> >>> > Initial opt-in "low-power" support for MacOS has landed in Firefox
>> 63
>> >>> > (Nightly).
>> >>>
>> >>> I assume opt-in means that your default value is "high-performance"?
>> >>>
>> >>> I wonder if we should make an effort to be consistent on this,
>> although I
>> >>> don't think Apple will want to move away from a "low-power" default.
>> >>> However, I wouldn't mind pushing for it to be "high-performance" if
>> the
>> >>> device is connected to a power supply. (Downside: assuming you're
>> already
>> >>> being tracked, and they know you're on a dual-GPU machine, a website
>> can now
>> >>> detect if you're connected to power)
>> >>>
>> >>> Dean
>> >>>
>> >>>
>> >>> >
>> >>> > On Fri, Mar 17, 2017 at 3:04 PM, Dean Jackson <[email protected]>
>> wrote:
>> >>> >>
>> >>> >> Hello WebGL community,
>> >>> >>
>> >>> >> We recently added powerPreference to the WebGL 1.0 specification,
>> >>> >> which allows content developers to give a hint as to what type of
>> GPU they
>> >>> >> require.
>> >>> >>
>> >>> >> https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2.1
>> >>> >>
>> >>> >> This replaces the old preferLowPowerToHighPerformance which, even
>> >>> >> though WebKit implemented it, never shipped in a form that
>> actually changed
>> >>> >> behaviour.
>> >>> >>
>> >>> >> Here's an example. If you're on a macOS system with two GPUs (e.g.
>> a
>> >>> >> Macbook Pro), you'd request the more powerful and power hungry GPU
>> using:
>> >>> >>
>> >>> >>    let gl = canvas.getContext("webgl", { powerPreference:
>> >>> >> "high-performance" });
>> >>> >>
>> >>> >> Note that, as the specification suggests, it doesn't guarantee
>> you'll
>> >>> >> get the GPU, and you'll be at the front of the line if the system
>> needs to
>> >>> >> reset some WebGL contexts in order to reclaim system resources.
>> You MUST
>> >>> >> have a registered event handler for the webglcontextlost and
>> >>> >> webglcontextrestored events if you want the user agent to respect
>> your
>> >>> >> request for high-performance.
>> >>> >>
>> >>> >> WebKit and Safari Technology Preview have implemented this
>> attribute,
>> >>> >> so you can try them out now. Some details on the current WebKit
>> >>> >> implementation:
>> >>> >>
>> >>> >> - the default value for powerPreference is equivalent to
>> "low-power"
>> >>> >> (i.e. we still prioritise power use).
>> >>> >> - even if you get the discrete GPU, you WILL swap to the integrated
>> >>> >> GPU if your tab is moved to the background, or the page is hidden.
>> This
>> >>> >> shouldn't cause any issues, but please let me know if you think it
>> is.
>> >>> >> - similarly, if you request "low-power" you might be swapped to the
>> >>> >> discrete GPU if another page or system app turns it on.
>> >>> >>
>> >>> >> Other browser engines are indicating they'll be implementing this
>> soon
>> >>> >> too. The behaviour on other operating systems and hardware might
>> be slightly
>> >>> >> different.
>> >>> >>
>> >>> >> Dean
>> >>> >>
>> >>> >>
>> >>> >> -----------------------------------------------------------
>> >>> >> You are currently subscribed to [email protected]
>> >>> >> To unsubscribe, send an email to [email protected] with
>> >>> >> the following command in the body of your email:
>> >>> >> unsubscribe public_webgl
>> >>> >> -----------------------------------------------------------
>> >>> >>
>> >>>
>> >>>
>> >>> -----------------------------------------------------------
>> >>> You are currently subscribed to [email protected]
>> >>> To unsubscribe, send an email to [email protected] with
>> >>> the following command in the body of your email:
>> >>> unsubscribe public_webgl
>> >>> -----------------------------------------------------------
>> >>>
>> >>
>> >
>>
>> -----------------------------------------------------------
>> You are currently subscribed to [email protected]
>> To unsubscribe, send an email to [email protected] with
>> the following command in the body of your email:
>> unsubscribe public_webgl
>> -----------------------------------------------------------
>>
>>
>
> --
> - rachid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20180702/3b0c5e6e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4845 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20180702/3b0c5e6e/attachment.p7s>


More information about the public_webgl mailing list