- From: Rick Waldron <waldron.rick@gmail.com>
- Date: Tue, 29 Apr 2014 14:05:17 -0400
- To: Brandon Jones <bajones@google.com>
- Cc: Mark Miller <erights@google.com>, Brendan Eich <brendan@secure.meer.net>, Boris Zbarsky <bzbarsky@mit.edu>, Webapps WG <public-webapps@w3.org>
- Message-ID: <CAHfnhfp3tLtYvpkoqHnwi6d0KXd+6M5r=SijhtN0+bjCBkfOaw@mail.gmail.com>
On Tue, Apr 29, 2014 at 1:45 PM, 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. > I'd prefer to be very wrong about this, but my immediate reaction to this is that it would be expensive to allocate these snapshot objects. Tell me where I'm misunderstanding: "SnapShot" 1. For each rAF turn: a. Let gp be a snapshot of gamepad b. Do stuff with one or more values from gp vs. "Live" 1. Let gp be gamepad 2. For each rAF turn: a. Do stuff with one or more values from gp The latter also follows the general model used in Node-based hardware programming/communication API designs. Rick > 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 >> >
Received on Tuesday, 29 April 2014 18:06:05 UTC