Closed Bug 1617434 Opened 3 years ago Closed 3 years ago

Avoid recreating reserved Clients when we process switch

Categories

(Core :: DOM: Workers, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: mattwoodrow, Assigned: mattwoodrow)

References

Details

Attachments

(5 files)

The current flow for creating ClientSources for document loads with DocumentChannel is:

  • The originating content process creates a reserved ClientSource for the initial URL of the load.
  • If a redirect is encountered, then the parent process allocates a ClientInfo (for a 'future' ClientSource) using the new URL.
  • If the load is to be delivered to the originating process:
    • If there were no redirects, then copy the reserved ClientSource across to the final channel.
    • If there were (so we have a ClientInfo), then we create a reserved ClientSource using that info (resolving the 'future' ClientSource). We also destroy the existing ClientSource created at the start.
  • If we had to switch processes and the load is delivered to the new one:
    • The new process unconditionally allocates a new reserved ClientSource (and ClientInfo!), and then we have to notify the parent of the new id to make sure we update the controlled client.
    • The old process is torn down, destroying the existing ClientSource.

I think we can simplify this to:

  • The parent process allocates a ClientInfo ('future' ClientSource) for both the initial URL, as well as any redirect URLs.
  • When we deliver the load to a process (either originating or new), then we create a reserved ClientSource around the most recent ClientInfo.
Assignee: nobody → matt.woodrow

This should be a no-op, but should make the following changes easier to reason about.

Rather than creating a ClientSource in the content process for the initial URL, this changes us to just create the ClientInfo in the parent, as we do for redirects.

Depends on D63805

Now that we're guaranteed to not have an existing ClientSource in the old process, we no longer need to allocate a new ClientInfo in the new process.
This lets us just create a ClientSource around the ClientInfo already on the channel (exactly as we do for same-process loads), and we no longer need to reconcile changes with the parent.

Depends on D63807

Blocks: 1617500
Blocks: 1617789
Priority: -- → P1
Pushed by mwoodrow@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1563faa24d15
Split ClientChannelHelper into three separate classes instead of having a mode variable. r=perry
https://hg.mozilla.org/integration/autoland/rev/c5f1f70efb88
Move reserved client creation to parent-side with DocumentChannel. r=perry
Keywords: leave-open
Pushed by mwoodrow@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3e91b3805158
Split ClientChannelHelper into three separate classes instead of having a mode variable. r=perry
https://hg.mozilla.org/integration/autoland/rev/c0f15f00e1c6
Move reserved client creation to parent-side with DocumentChannel. r=perry
Flags: needinfo?(matt.woodrow)
Pushed by mwoodrow@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a4b2284d5325
Don't recreate ClientSource when we process switch. r=perry
https://hg.mozilla.org/integration/autoland/rev/2c557fca99ed
Simplify ClientChannelHelperChild. r=perry
https://hg.mozilla.org/integration/autoland/rev/713b5f2a3735
Share code where possible in ClientChannelHelper. r=perry
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Keywords: leave-open
You need to log in before you can comment on or make changes to this bug.