Re: [Gamepad] Liveness of Gamepad objects

I think both semantics are workable. I'd likely prefer the gamepad state to
be immutable from JS, because assigning state there is smelly. I'd also
prefer the option that incurs less GC overhead if possible. Beyond that, I
just think the implementations should be semantically and symbolically
identical.


On Tue, Apr 29, 2014 at 9:19 PM, Mark S. Miller <erights@google.com> wrote:

>
>
>
> On Tue, Apr 29, 2014 at 11:07 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>
>> On 4/29/14, 1:46 PM, Mark S. Miller wrote:
>>
>>> How would either make GC observable?
>>>
>>
>> Consider the following code:
>>
>>   navigator.getGamepads()[0].foo = 5;
>>   var intervals = 0;
>>   var id = setInterval(function() {
>>     ++intervals;
>>     if (navigator.getGamepads()[0].foo != 5) {
>>       alert("What happened after " + intervals + " intervals?");
>>       clearInterval(id);
>>     }
>>   }, 1000);
>>
>> In Chrome's current implementation, where getGamepads() returns a new
>> object each time getGamepads()[0] is a new object each time this will
>> consistently alert "What happened after 1 intervals?".
>>
>> In Firefox's current implementation this will not alert at all unless the
>> set of connected gamepads changes.
>>
>> In an implementation which brokenly GCed and lazily recreated the JS
>> reflections of Gamepad objects, the alert could happen after some random
>> number of intervals, depending on GC timing.
>>
>
> I see. Let's not do that then ;).
>
>
>
>>
>> Does that help?
>>
>> -Boris
>>
>
>
>
> --
>     Cheers,
>     --MarkM
>

Received on Tuesday, 29 April 2014 19:28:12 UTC