Closed Bug 1477561 Opened 6 years ago Closed 6 years ago

Improve handling of shared memory preference data when spawning recording processes

Categories

(Core Graveyard :: Web Replay, enhancement)

enhancement
Not set
normal

Tracking

(firefox63 fixed)

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: bhackett1024, Assigned: bhackett1024)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached patch patchSplinter Review
Currently, shared memory preference data from the UI process is conveyed to a recording process via a fair amount of glue when the middleman starts that recording process.  After a recent rebase there is an additional block of preferences data that is now conveyed to child processes, which also needs handling.

Rather than making the record/replay glue even more complicated, this patch removes all the associated instrumentation and glue, and simply maps the file descriptors in the middleman so that the recording process can access them.  The existing redirections used to record/replay mmap'ed file descriptor contents are sufficient to take care of recording/replaying this data.
Attachment #8994028 - Flags: review?(continuation)
Assignee: nobody → bhackett1024
Comment on attachment 8994028 [details] [diff] [review]
patch

Review of attachment 8994028 [details] [diff] [review]:
-----------------------------------------------------------------

It is always nice to see things get simpler.
Attachment #8994028 - Flags: review?(continuation) → review+
Comment on attachment 8994028 [details] [diff] [review]
patch

Review of attachment 8994028 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/recordreplay/ipc/ChildProcess.cpp
@@ +465,5 @@
>      MOZ_RELEASE_ASSERT(!gRecordingProcess);
>      gRecordingProcess = new ipc::GeckoChildProcessHost(GeckoProcessType_Content);
> +
> +    gRecordingProcess->AddFdToRemap(kPrefsFileDescriptor, kPrefsFileDescriptor);
> +    gRecordingProcess->AddFdToRemap(kPrefMapFileDescriptor, kPrefMapFileDescriptor);

We clone this FD and close the original immediately at child process startup. The IPC FileDescriptor stuff is weird enough that we wind up cloning it again soon afterwards, and that probably winds up reusing the original descriptor that we closed, but that isn't something we should rely on.

You'll probably need to call Preferences::EnsureSnapshot again, and move the IsParentProcess assertion inside the `if (!gSharedMap)`
As far as I can tell, with the existing patch the middleman is still using the original file descriptors when spawning the recording process --- this is done synchronously under the InitializeMiddleman() call made by ContentProcess::Init(), before the descriptors have been closed.  It sure is opaque and fragile, though.  This supplemental patch explicitly passes the handles around to make the code clearer and get some assurance the handles won't be closed before they can be passed down to the recording process.
Attachment #8994373 - Flags: review?(kmaglione+bmo)
Sorry, the patch I just attached has some extraneous changes.
Attachment #8994373 - Attachment is obsolete: true
Attachment #8994373 - Flags: review?(kmaglione+bmo)
Attachment #8994374 - Flags: review?(kmaglione+bmo)
Comment on attachment 8994374 [details] [diff] [review]
Part 2 - Explicitly pass pref handles around when spawning recording processes.

Review of attachment 8994374 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks
Attachment #8994374 - Flags: review?(kmaglione+bmo) → review+
Pushed by bhackett@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5dc6db674236
Improve handling of shared memory preference data when spawning recording processes, r=mccr8.
https://hg.mozilla.org/integration/mozilla-inbound/rev/c47a0754222c
Part 2 - Explicitly pass pref handles around when spawning recording processes, r=kmag.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: