-
-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
When idle checking is on, every mouse move, keystroke, and scroll event calls wake which iterates through an array of old timers and clears them (though only effectively clearing the last timer which would be the only one ever active). This array grows unbounded with each event. An array should not be used here.
Current:
trackIdleStatus = ->
timer = []
wakeUp = ->
timer.map(clearTimeout);
ifvisible.wakeup() if status isnt "active"
idleStartedTime = +(new Date())
timer.push setTimeout(->
ifvisible.idle() if status is "active"
, idleTime)
...Fix:
trackIdleStatus = ->
timer = null # No array, just a reference to the last timeout id
wakeUp = ->
clearTimeout(timer); # Clear previous timeout. A noop if the timeout already ran
ifvisible.wakeup() if status isnt "active"
idleStartedTime = +(new Date())
timer = setTimeout(->
ifvisible.idle() if status is "active"
, idleTime)
...Metadata
Metadata
Assignees
Labels
No labels