Closed smaug---- closed 7 years ago
The implementation in Chrome keeps an absolute deadline time internally in the IdleDeadline object, with timeRemaining() being the relative time between this deadline and performance.now() (with a floor of 0). This means the timeRemaining counts down to this deadline even if after the callback call (and then stays at zero once it reaches it).
It feels like it might be useful to allow the IdleDeadline to continue to keep the deadline even after the callback, but I'm not sure whether we should spec this - it might cause issues for other implementations or limit our future flexibility in updating the deadline if external events arrive. @igrigorik, @toddreifsteck, @bzbarsky any thoughts?
I don't have any thoughts offhand.
I don't think it really matters much what is spec'ed here, just that some behavior is spec'ed.
I agree with @smaug---- . We should either outline future use cases are spec IdleDeadline as well as we can within our current use cases.
https://w3c.github.io/requestidlecallback/#the-timeremaining-method
Let timeRemaining be deadline - now. If timeRemaining is negative, set it to 0.
Is this not sufficient? =/
The problem is in step 1 of the algorithm: there is no "associated callback" at that point, so "the deadline of the associated callback" is not defined at all.
Ah, ok, I see the confusion. So, in 5.2 (Invoke idle callbacks algorithm) we have..
Let deadlineArg be an IdleDeadline constructed with the given deadline and the didTimeout attribute set to false.
In other words, IdleDeadline has a references to deadline time. Can we just drop step 1 in 4.3 (Let deadline be the..) to clear this up? Alternatively, we could spell it out.. "Lead idledeadline be the DOMHighResTimestamp value of the deadline argument of IdleDeadline", or some such?
Yes this sounds good to me. Dropping step 1 (and also updating the "callback's deadline" with "the deadline argument passed to IdleDeadline" in the paragraph above) would be my preference if it is clear enough to everyone else.
That seems fine, yes.
I assume it should be 0, but the spec language doesn't really capture that case, since there isn't any associated callback anymore at that time.