Bug 181155 - Add a ProcessIdentifier, vended from the UI process, to each child process
Summary: Add a ProcessIdentifier, vended from the UI process, to each child process
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks: 181172
  Show dependency treegraph
 
Reported: 2017-12-25 22:38 PST by Brady Eidson
Modified: 2019-01-28 17:54 PST (History)
5 users (show)

See Also:


Attachments
Patch (20.97 KB, patch)
2017-12-26 21:46 PST, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (21.24 KB, patch)
2017-12-28 20:03 PST, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2017-12-25 22:38:48 PST
Add a ProcessIdentifier, vended from the UI process, to each child process

This will make it painless to guarantee globally unique object identifiers no matter which process generates an object identifier as long as the process identifier is included in the mix.
Comment 1 Brady Eidson 2017-12-26 21:46:23 PST
Created attachment 330209 [details]
Patch
Comment 2 Brent Fulgham 2017-12-28 13:39:58 PST
Comment on attachment 330209 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=330209&action=review

Looks good! I had a few idle thoughts, but nothing you need to address before landing. r=me.

> Source/WebCore/ChangeLog:4
> +        https://bugs.webkit.org/show_bug.cgi?id=181155

Yes, please.

> Source/WebCore/platform/Process.cpp:46
> +    static bool hasInitialized;

Don't we usually prefer a dispatch_once for this kind of initialization? Maybe we don't for cross-platform code.

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^ {
        globalIdentifier = generateObjectIdentifier<ProcessIdentifierType>();
    });

> Source/WebKit/Shared/ChildProcess.cpp:73
> +#endif

I think 'processIdentifier' is guaranteed to exist (on all platforms), since you default initialize it in the ChildProcessProxy, and always add it to the init parameters in getLaunchOptions.

> Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:90
> +    if (processIdentifierString.isEmpty())

Should this assert? It would be super weird if this ever failed, wouldn't it?
Comment 3 Brady Eidson 2017-12-28 19:50:07 PST
(In reply to Brent Fulgham from comment #2)
> Comment on attachment 330209 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=330209&action=review
> 
> Looks good! I had a few idle thoughts, but nothing you need to address
> before landing. r=me.
> 
> > Source/WebCore/ChangeLog:4
> > +        https://bugs.webkit.org/show_bug.cgi?id=181155
> 
> Yes, please.
> 
> > Source/WebCore/platform/Process.cpp:46
> > +    static bool hasInitialized;
> 
> Don't we usually prefer a dispatch_once for this kind of initialization?
> Maybe we don't for cross-platform code.

Right, cross platform. That said I totally remembered std::once_flag and std::call_once since I uploaded this - Will use that instead.

> 
>     static dispatch_once_t onceToken;
>     dispatch_once(&onceToken, ^ {
>         globalIdentifier = generateObjectIdentifier<ProcessIdentifierType>();
>     });
> 
> > Source/WebKit/Shared/ChildProcess.cpp:73
> > +#endif
> 
> I think 'processIdentifier' is guaranteed to exist (on all platforms), since
> you default initialize it in the ChildProcessProxy, and always add it to the
> init parameters in getLaunchOptions.

It's always added to LaunchOptions in ChildProcessProxy in the UI process, that is true.
Unfortunately:
 - In the child process itself the code that populates ChildProcessInitializationParameters is platform-specific, and I can only write the Cocoa port
 - WK1 is still a thing.

> 
> > Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:90
> > +    if (processIdentifierString.isEmpty())
> 
> Should this assert? It would be super weird if this ever failed, wouldn't it?

That's handled in XPCServiceInitializer where the delegates to populate these things are called.

e.g.:
    if (!delegate.getProcessIdentifier(processIdentifier))
        exit(EXIT_FAILURE);
Comment 4 Brady Eidson 2017-12-28 20:03:28 PST
Created attachment 330244 [details]
Patch
Comment 5 WebKit Commit Bot 2017-12-28 21:56:33 PST
Comment on attachment 330244 [details]
Patch

Clearing flags on attachment: 330244

Committed r226308: <https://trac.webkit.org/changeset/226308>
Comment 6 WebKit Commit Bot 2017-12-28 21:56:34 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2018-01-02 13:18:23 PST
<rdar://problem/36261367>