Re: [Gamepad] Liveness of Gamepad objects

How would either make GC observable?


On Tue, Apr 29, 2014 at 10:45 AM, Brandon Jones <bajones@google.com> wrote:

> On Tue Apr 29 2014 at 10:24:48 AM, Mark S. Miller <erights@google.com>
> wrote:
>
>> I don't know anything about Gamepad. Could someone provide enough context
>> that I can understand the question? Thanks.
>>
>
> The Gamepad API returns an array of Gamepad state objects when you call
> getGamepads(), like so:
>
> requestAnimationFrame(function() {
>     var gamepads = navigator.getGamepads();
>     var playerGamepad = gamepads[0];
>     if (playerGamepad.buttons[0].pressed) {
>         player.jump();
>     }
> }
>
> That code currently would work in both Firefox and Chrome. The "Liveness"
> question concerns the following code:
>
> var gamepads = navigator.getGamepads();
> var playerGamepad = gamepads[0];
> requestAnimationFrame(function() {
>     if (playerGamepad.buttons[0].pressed) {
>         player.jump();
>     }
> }
>
> In Firefox this code will be functionally equivalent to the first code
> snippet, since it continues to update the values Gamepad state object after
> you've acquired it. AKA: The object is "live".
>
> In Chrome, however, the gamepad state returned is a snapshot and as such
> the second code snippet will not observe changes to the gamepad input.
>
> The spec is currently ambiguous on the matter, so we want to clarify
> whether or not the second code snippet is valid or not and update the
> browser implementations accordingly.
>
> --Brandon
>
>
>> On Tue, Apr 29, 2014 at 10:16 AM, Brendan Eich <brendan@secure.meer.net>wrote:
>>
>>> Boris Zbarsky wrote:
>>>
>>>> For what it's worth, the way Gecko implements this is by setting up
>>>> that lifetime guarantee only when an expando is added to the object (or
>>>> some other things, like use as a WeakMap key, happen).  Until then we allow
>>>> it to be GCed.
>>>>
>>>
>>> What do other engines do in general? Unobservable GC is a requirement,
>>> if you ask me and Mark Miller.
>>>
>>> /be
>>>
>>
>>
>>
>> --
>>     Cheers,
>>     --MarkM
>>
>


-- 
    Cheers,
    --MarkM

Received on Tuesday, 29 April 2014 17:47:21 UTC