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