Closed Bug 1805932 Opened 2 years ago Closed 2 years ago

Put all background process Main Threads on Macos in the background

Categories

(Core :: XPCOM, enhancement)

ARM64
macOS
enhancement

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox114 --- fixed

People

(Reporter: KrisWright, Assigned: KrisWright)

References

Details

Attachments

(1 file, 1 obsolete file)

Followup for bug 1748378, we can use this API to put all XPCOM threads in the background. We follow a few particular steps:

  • Identify some IsOperatingInBackground atomic, likely held by the thread manager
  • When threads see this value (eg not doing any work), they may put themselves in the background
  • Threads may save their previous operating state to restore when leaving the background.

I think this process may also work for the main thread by sending a task directly to the main thread to set/unset itself.

Attachment #9314284 - Attachment description: WIP: Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority. → Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority.
Attachment #9314284 - Attachment description: Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority. → WIP: Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority.
Assignee: nobody → kwright
Attachment #9314284 - Attachment description: WIP: Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority. → Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority.
Status: NEW → ASSIGNED
Attachment #9314284 - Attachment description: Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets bacground priority. → Bug 1805932 - Put the main thread in the background when the ProcessPriorityManager sets background priority. r?florian,nika

This part is especially tricky and what exists here so far is what I am using to test the behavior. Notifying the threads that they need to go into the background is where the main hangup is - preventing spurious wakeups while also noticing the change. To solve this I am dealing with a global background value which threads can check during dispatch. If they notice there has been a measurable change, they can dispatch to their own event target first a method to set themselves into the background. I haven't worked out yet how we'll be notifying the mechanism of the changes.

Depends on D167952

Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7f1af097474e Put the main thread in the background when the ProcessPriorityManager sets background priority. r=nika,florian
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
See Also: → 1832365
See Also: → 1832368

Comment on attachment 9326333 [details]
WIP: Bug 1805932 - Implement background behavior for all nsThreads.

Revision D174309 was moved to bug 1832368. Setting attachment 9326333 [details] to obsolete.

Attachment #9326333 - Attachment is obsolete: true

We split up the mainthread work and any offthread work so we can move forward with testing new changes. Work on offthread changes will continue in bug 1832368.

Summary: Put all background process nsThreads on Macos in the background → Put all background process Main Threads on Macos in the background
See Also: → 1895985
Blocks: 1895985
See Also: 1895985
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: