Closed Bug 1737828 Opened 4 years ago Closed 4 years ago

Don't require the main thread to start PBackground instances

Categories

(Core :: IPC, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
98 Branch
Tracking Status
firefox98 --- fixed

People

(Reporter: nika, Assigned: nika)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Currently, starting a PBackground actor always requires visiting the main threads in both the creating process and the target process due to the existing design and requiring main-thread actors for messaging of Endpoint instances. We could instead create the actors with an actor which runs on a background TaskQueue in content processes, and the background thread in the parent process. Messages would be bounced to this task queue instead of to the main thread, potentially greatly decreasing latency.

This patch avoids requiring the main thread to create PBackground instances by
instead using a background starter TaskQueue, and sending messages from a
PBackgroundStarter actor hosted on that thread to the target background thread
directly. On the background thread, the relevant metadata is already registered
and present in the BackgroundStarterParent actor allowing the main thread in
both processes to be bypassed completely.

Various tasks remain bound to the main thread, such as PBackground cleanup and
async steps involved in PBackground creation.

This patch also unifies the in-process and cross-process PBackground codepaths,
allowing in-process PBackground creation to bypass the main thread as well, and
removing the need for a main thread event target from
GetOrCreateForCurrentThread().

Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/43cd1d6eb145 Avoid the main thread when starting PBackground, r=asuth,ipc-reviewers,necko-reviewers,kershaw,handyman
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 98 Branch
Depends on: 1749744
Regressions: 1749744
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: