RESOLVED FIXED191722
[Mac] Regression: WebContent process's display name is no longer set
https://bugs.webkit.org/show_bug.cgi?id=191722
Summary [Mac] Regression: WebContent process's display name is no longer set
Chris Dumez
Reported 2018-11-15 15:51:25 PST
WebContent process's display name is no longer set and is thus not reported in Activity Monitor.
Attachments
Patch (3.71 KB, patch)
2018-11-15 15:58 PST, Chris Dumez
no flags
Patch (4.38 KB, patch)
2018-11-16 08:48 PST, Chris Dumez
no flags
Patch (4.91 KB, patch)
2018-11-16 08:57 PST, Chris Dumez
no flags
Patch (4.91 KB, patch)
2018-11-16 09:15 PST, Chris Dumez
no flags
Patch (4.90 KB, patch)
2018-11-16 09:33 PST, Chris Dumez
no flags
Patch (4.92 KB, patch)
2018-11-16 09:40 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2018-11-15 15:51:43 PST
Chris Dumez
Comment 2 2018-11-15 15:58:24 PST
Brent Fulgham
Comment 3 2018-11-15 18:50:41 PST
Comment on attachment 354994 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=354994&action=review > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:228 > + auto error = _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr); As long as this is happening after we enter the sandbox, we should be fine. Per Arne: Can you help make sure this isn't opening a side channel to WindowServer?
Chris Dumez
Comment 4 2018-11-16 08:44:32 PST
Comment on attachment 354994 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=354994&action=review > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:353 > + [NSApplication sharedApplication]; If you'd prefer, it would also work if I called _RegisterApplication(NULL, NULL); Let me know if you'd prefer that.
Per Arne Vollan
Comment 5 2018-11-16 08:46:01 PST
(In reply to Chris Dumez from comment #4) > Comment on attachment 354994 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=354994&action=review > > > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:353 > > + [NSApplication sharedApplication]; > > If you'd prefer, it would also work if I called _RegisterApplication(NULL, > NULL); > Let me know if you'd prefer that. Yes, I think that would be better, since we are trying to avoid calling [NSApplication sharedApplication].
Chris Dumez
Comment 6 2018-11-16 08:48:31 PST
Chris Dumez
Comment 7 2018-11-16 08:51:17 PST
(In reply to Per Arne Vollan from comment #5) > (In reply to Chris Dumez from comment #4) > > Comment on attachment 354994 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=354994&action=review > > > > > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:353 > > > + [NSApplication sharedApplication]; > > > > If you'd prefer, it would also work if I called _RegisterApplication(NULL, > > NULL); > > Let me know if you'd prefer that. > > Yes, I think that would be better, since we are trying to avoid calling > [NSApplication sharedApplication]. Ok, will re-upload a patch shortly.
Chris Dumez
Comment 8 2018-11-16 08:57:39 PST
Per Arne Vollan
Comment 9 2018-11-16 09:03:21 PST
Comment on attachment 355062 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355062&action=review > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:240 > + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ > + // Note that it is important for [NSApplication sharedApplication] to have been called before setting the display name. > + auto error = _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr); > + ASSERT(!error); > + if (error) { > + RELEASE_LOG_ERROR(Process, "Failed to set the display name of the WebContent process, error code: %d", error); > + return; > + } > +#if !ASSERT_DISABLED > + // It is possible for _LSSetApplicationInformationItem() to return 0 and yet fail to set the display name so we make sure the display name has actually been set. > + String actualApplicationName = adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get(); > + ASSERT(!actualApplicationName.isEmpty()); > +#endif > + }); Can this be called synchronously now?
Chris Dumez
Comment 10 2018-11-16 09:04:52 PST
(In reply to Per Arne Vollan from comment #9) > Comment on attachment 355062 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=355062&action=review > > > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:240 > > + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ > > + // Note that it is important for [NSApplication sharedApplication] to have been called before setting the display name. > > + auto error = _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr); > > + ASSERT(!error); > > + if (error) { > > + RELEASE_LOG_ERROR(Process, "Failed to set the display name of the WebContent process, error code: %d", error); > > + return; > > + } > > +#if !ASSERT_DISABLED > > + // It is possible for _LSSetApplicationInformationItem() to return 0 and yet fail to set the display name so we make sure the display name has actually been set. > > + String actualApplicationName = adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get(); > > + ASSERT(!actualApplicationName.isEmpty()); > > +#endif > > + }); > > Can this be called synchronously now? This is intentional, for performance reasons. This has been measured as costly during process launch and the _LS API is thread-safe.
Chris Dumez
Comment 11 2018-11-16 09:05:56 PST
(In reply to Chris Dumez from comment #10) > (In reply to Per Arne Vollan from comment #9) > > Comment on attachment 355062 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=355062&action=review > > > > > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:240 > > > + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ > > > + // Note that it is important for [NSApplication sharedApplication] to have been called before setting the display name. > > > + auto error = _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr); > > > + ASSERT(!error); > > > + if (error) { > > > + RELEASE_LOG_ERROR(Process, "Failed to set the display name of the WebContent process, error code: %d", error); > > > + return; > > > + } > > > +#if !ASSERT_DISABLED > > > + // It is possible for _LSSetApplicationInformationItem() to return 0 and yet fail to set the display name so we make sure the display name has actually been set. > > > + String actualApplicationName = adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get(); > > > + ASSERT(!actualApplicationName.isEmpty()); > > > +#endif > > > + }); > > > > Can this be called synchronously now? > > This is intentional, for performance reasons. This has been measured as > costly during process launch and the _LS API is thread-safe. In order words, it would work if I did it synchronously but it'd slow process WebProcess initialization by a few milliseconds unnecessarily.
Per Arne Vollan
Comment 12 2018-11-16 09:11:02 PST
Comment on attachment 355062 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355062&action=review R=me. > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:228 > + // Note that it is important for [NSApplication sharedApplication] to have been called before setting the display name. Replace [NSApplication sharedApplication] with _RegisterApplication. > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:355 > + _RegisterApplication(NULL, NULL); NULL -> nullptr
Chris Dumez
Comment 13 2018-11-16 09:15:03 PST
Chris Dumez
Comment 14 2018-11-16 09:33:13 PST
Chris Dumez
Comment 15 2018-11-16 09:40:44 PST
WebKit Commit Bot
Comment 16 2018-11-16 10:53:08 PST
Comment on attachment 355067 [details] Patch Clearing flags on attachment: 355067 Committed r238289: <https://trac.webkit.org/changeset/238289>
WebKit Commit Bot
Comment 17 2018-11-16 10:53:10 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.