Closed Bug 1788050 Opened 2 years ago Closed 1 year ago

Use Timer.sys.mjs module instead of "setTimeout" in modules running in child processes

Categories

(Remote Protocol :: Agent, enhancement, P3)

enhancement

Tracking

(firefox115 fixed)

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: whimboo, Assigned: victoria.o.ajala, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [webdriver:m7][webdriver:external][lang=js][webdriver:relnote])

Attachments

(1 file)

With the feedback that I got from Olli Pettay when I talked with him about performance and power usage we should not use setTimeout() in our JSM code that runs in content processes. Problem is that these window timers are throttled when the tab runs in the background.

While this might not be a big deal for Marionette given that most tests run with the tab under test in the foreground this would be an issue for BiDi.

Instead it is preferred to use the low-level API as provided by nsITimer because no throttling will happen here.

Instances of setTimeout that we have under /remote/ can be found here:

https://searchfox.org/mozilla-central/search?q=setTimeout%28&path=remote%2F**%2F*.mjs&case=false&regexp=false

Another option would clearly be the Timer.sys.mjs module as well given that it offers a better interface for timer management.

Summary: Use nsITimer intances instead of "setTimeout" in modules running in child processes → Use nsITimer or Timer.jsm instead of "setTimeout" in modules running in child processes
Priority: -- → P3
Whiteboard: [webdriver:backlog]
Blocks: 1827818

I spoke with Olli and the Timer.sys.mjs is only a small wrapper so it wont make much of a difference. As such to have a similar usage with other code under /remote lets make use of this module.

Mentor: hskupin
Summary: Use nsITimer or Timer.jsm instead of "setTimeout" in modules running in child processes → Use Timer.sys.mjs module instead of "setTimeout" in modules running in child processes
Whiteboard: [webdriver:backlog] → [webdriver:backlog][lang=js]

I'm working on this!

Hi Victoria. I want to check with you if everything is still fine and that you know how to proceed on this bug. Or do you need any further information from my side? Thanks!

Flags: needinfo?(victoria.o.ajala)

Hi @whimboo, I fell a bit sick over the weekend and I was unable to work but I will create a patch for this fix shortly :)

Flags: needinfo?(victoria.o.ajala)
Assignee: nobody → victoria.o.ajala
Status: NEW → ASSIGNED
Attachment #9331369 - Attachment description: Bug 1788050 - Used Timer.sys.mjs module instead of setTimeout in modules running in child processes. r=whimboo → Bug 1788050 - [remote] Use timer from Timer.sys.mjs to prevent throttling in background tabs
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8f7b3d149a70 [remote] Use timer from Timer.sys.mjs to prevent throttling in background tabs r=whimboo,webdriver-reviewers
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Whiteboard: [webdriver:backlog][lang=js] → [webdriver:m7] [lang=js]
Whiteboard: [webdriver:m7] [lang=js] → [webdriver:m7][webdriver:external][lang=js]
Whiteboard: [webdriver:m7][webdriver:external][lang=js] → [webdriver:m7][webdriver:external][lang=js][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: