Re: [whatwg] Proposal: Wake Lock API

On 14 August 2014 03:07, Jonas Sicking <jonas@sicking.cc> wrote:
> On Wed, Aug 13, 2014 at 9:46 PM, Biju <bijumaillist@gmail.com> wrote:
>>
>> On 13 August 2014 21:00, Jonas Sicking <jonas@sicking.cc> wrote:
>>>
>>> An alternative design would be something like
>>>
>>> x = new WakeLock("display");
>>> x.request();
>>> x.release();
>>>
>>> Extra calls of either request() or release() are ignored, but pages
>>> can create any number of WakeLocks of the same type.
>>
>> If application made a x.request() then "x" got garbage collected
>> system should automatically do x.release();
>
> No. We don't want authors to come to rely on GC to have their locks
> released. That would cause very erratic behavior where sometimes the
> lock would be held for 2 seconds after the last reference to 'x' was
> removed, and sometimes the lock would be held for 30 minutes past that
> point.
>
> In other words, it would make GC observable. Not always observable by
> the page, but by the user which can be just as bad.
>
> / Jonas

So what happens when we have following function call.
How do we release the runaway lock request.
Another case is a page made lock and user navigate away from the page.
Do the browser keep the lock for ever ?

function xyz(){

    do_something_1();

    x = new WakeLock("display");
    x.request();

    do_something_2();

   throw "some runtime error occurred";

    do_something_3();

    x.release();

    do_something_4();
}

Received on Thursday, 14 August 2014 11:45:19 UTC