If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Idle timeout doesn't always happen as expected with the `idle` api

NEW
Unassigned

Status

()

Toolkit
WebExtensions: Untriaged
P5
normal
2 months ago
14 days ago

People

(Reporter: pmorris, Unassigned)

Tracking

55 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 months ago
The idle timeout with the idle api[0] doesn't always work as expected.

I'm working on porting "Mind the Time"[1] to WebExtensions and have uploaded some beta releases.  Sometimes I'll leave my laptop sitting for awhile with a tab/window activated/focused.  Usually the idle timeout will happen and the right amount of time will be logged for the current domain, but sometimes the idle timeout does not happen and way too much time is logged.

This is on FF 55.0 dev edition, multi-process, on Ubuntu 16.04, with my own profile with many open tabs, other add-ons, and several windows open.  I've added console logging to the beta version of Mind the Time to explore the issue and it shows that the idle timeout does not always fire when I expect it to.

This leads to a regression in my addon's functionality that's blocking its migration to WebExtensions.

[0] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/idle
[1] https://addons.mozilla.org/en-US/firefox/addon/mind-the-time/

Updated

2 months ago
Flags: needinfo?(amckay)

Comment 1

2 months ago
This sounds similar to bug 1359403, although that talks about alarms and suspension but not sure if its a duplicate. See also bug 1377744.
Flags: needinfo?(amckay)
Priority: -- → P5
(Reporter)

Comment 2

24 days ago
I don't think this is a duplicate of either of those other bugs.  This one involves the `idle` api and AFAICT the others don't.  This bug is tricky because mostly the idle timeout works, but when it doesn't it makes the time logged by my add-on incorrect, sometimes making it off by many hours.  And that messes up its primary functionality.
(Reporter)

Comment 3

22 days ago
I made a simple add-on to help with detecting/reproducing the issue:
https://addons.mozilla.org/en-US/firefox/addon/idle-api-tester/

Comment 4

15 days ago
Paul, sorry for the slow reply but can you narrow this down a bit?  Did the non-webextension version of Mind the Time use nsIIdleService?  And are the quirks you're seeing unique to webextensions?  (ie, did you see similar things when using nsIIdleService directly?)
Flags: needinfo?(paul)
(Reporter)

Comment 5

14 days ago
Sure thing.  Before webextensions Mind the Time was built with the add-on sdk, and used the sdk's lower level apis for idle timeout functionality.  Below is the code that uses "sdk/system/events" and "user-interaction-active".  I've only seen these quirks after converting to webextensions, not with the previous sdk version of the add-on.

let systemEvents = require("sdk/system/events");

exports.addActivityListener = function(callback) {
    systemEvents.on("user-interaction-active", callback);
};

exports.removeActivityListener = function(callback) {
    systemEvents.off("user-interaction-active", callback);
};
Flags: needinfo?(paul)
You need to log in before you can comment on or make changes to this bug.