Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: User-friendly name for the GPUProcess no longer gets set #15356

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Jun 28, 2023

73df24e

Regression: User-friendly name for the GPUProcess no longer gets set
https://bugs.webkit.org/show_bug.cgi?id=258600

Reviewed by Per Arne Vollan and Brent Fulgham.

Access to launch services has been blocked by the GPUProcess' sandbox. As a
result, the GPUProcess no longer gets a user-friendly name in Activity Monitor.

To address the issue, we now:
1. Have the UIProcess create a sandbox extension for launch services and send it
   to the GPUProcess to temporarily consume it during initialization
2. The GPUProcess, on initialization now consumes this extension
3. The GPUProcess checks in with Launch Services and sets the process name
4. The GPUProcess closes connections to launch services
5. The GPUProcess revokes the sandbox extension

* Source/WebKit/GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::initializeGPUProcess):
* Source/WebKit/GPUProcess/GPUProcess.h:
* Source/WebKit/GPUProcess/GPUProcessCreationParameters.cpp:
(WebKit::GPUProcessCreationParameters::encode const):
(WebKit::GPUProcessCreationParameters::decode):
* Source/WebKit/GPUProcess/GPUProcessCreationParameters.h:
* Source/WebKit/GPUProcess/cocoa/GPUProcessCocoa.mm:
(WebKit::GPUProcess::platformInitializeGPUProcess):
* Source/WebKit/GPUProcess/mac/GPUProcessMac.mm:
(WebKit::GPUProcess::initializeProcessName):
(WebKit::GPUProcess::updateProcessName):
* Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in:
* Source/WebKit/UIProcess/Cocoa/GPUProcessProxyCocoa.mm:
(WebKit::GPUProcessProxy::platformInitializeGPUProcessParameters):

Canonical link: https://commits.webkit.org/265610@main

566993e

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@cdumez cdumez self-assigned this Jun 28, 2023
@cdumez cdumez added the WebKit2 Bugs relating to the WebKit2 API layer label Jun 28, 2023
@cdumez cdumez requested a review from pvollan June 28, 2023 04:11
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 28, 2023
@@ -63,8 +63,19 @@
void GPUProcess::initializeProcessName(const AuxiliaryProcessInitializationParameters& parameters)
{
#if !PLATFORM(MACCATALYST)
// Register the application. This will also check in with Launch Services.
// This is necessary to set the process name.
_RegisterApplication(nullptr, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sufficient to just check in with Launch Services? I do not think the Networking process calls _RegisterApplication?

// Set process name before initializing the sandbox as we may need to
// connect to launch services to set the name and the sandbox doesn't
// necessarily allow it.
initializeProcessName(parameters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could create a sandbox extension for Launch Services, which would be revoked after setting the process name?

@cdumez cdumez removed the merging-blocked Applied to prevent a change from being merged label Jun 28, 2023
_LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSPersistenceSuppressRelaunchAtLoginKey, kCFBooleanTrue, nullptr);

if (launchServicesExtension)
launchServicesExtension->revoke();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good if we closed any open LS connections here.

Comment on lines 112 to 115
// Disable relaunch on login. This is also done from -[NSApplication init] by dispatching -[NSApplication disableRelaunchOnLogin] on a non-main thread.
// This will be in a race with the closing of the Launch Services connection, so call it synchronously here.
// The cost of calling this should be small, and it is not expected to have any impact on performance.
_LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSPersistenceSuppressRelaunchAtLoginKey, kCFBooleanTrue, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required in the GPU process, since it was a workaround for a sandbox issue when NSApplication is being used in the WebContent process.

Copy link
Contributor

@pvollan pvollan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! R=me.

Comment on lines +106 to +117
// It is important to check in with launch services before setting the process name.
launchServicesCheckIn();

// Update process name while holding the Launch Services sandbox extension
updateProcessName();

// Close connection to launch services.
#if HAVE(HAVE_LS_SERVER_CONNECTION_STATUS_RELEASE_NOTIFICATIONS_MASK)
_LSSetApplicationLaunchServicesServerConnectionStatus(kLSServerConnectionStatusDoNotConnectToServerMask | kLSServerConnectionStatusReleaseNotificationsMask, nullptr);
#else
_LSSetApplicationLaunchServicesServerConnectionStatus(kLSServerConnectionStatusDoNotConnectToServerMask, nullptr);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this could be moved into the if (launchServicesExtension) clause, since it will not work without the extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it hurt to keep as is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping as-is is fine :)

@cdumez cdumez marked this pull request as ready for review June 28, 2023 21:53
Copy link
Contributor

@brentfulgham brentfulgham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, too, assuming you adopt Per Arne's requested changes.

@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Jun 29, 2023
https://bugs.webkit.org/show_bug.cgi?id=258600

Reviewed by Per Arne Vollan and Brent Fulgham.

Access to launch services has been blocked by the GPUProcess' sandbox. As a
result, the GPUProcess no longer gets a user-friendly name in Activity Monitor.

To address the issue, we now:
1. Have the UIProcess create a sandbox extension for launch services and send it
   to the GPUProcess to temporarily consume it during initialization
2. The GPUProcess, on initialization now consumes this extension
3. The GPUProcess checks in with Launch Services and sets the process name
4. The GPUProcess closes connections to launch services
5. The GPUProcess revokes the sandbox extension

* Source/WebKit/GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::initializeGPUProcess):
* Source/WebKit/GPUProcess/GPUProcess.h:
* Source/WebKit/GPUProcess/GPUProcessCreationParameters.cpp:
(WebKit::GPUProcessCreationParameters::encode const):
(WebKit::GPUProcessCreationParameters::decode):
* Source/WebKit/GPUProcess/GPUProcessCreationParameters.h:
* Source/WebKit/GPUProcess/cocoa/GPUProcessCocoa.mm:
(WebKit::GPUProcess::platformInitializeGPUProcess):
* Source/WebKit/GPUProcess/mac/GPUProcessMac.mm:
(WebKit::GPUProcess::initializeProcessName):
(WebKit::GPUProcess::updateProcessName):
* Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in:
* Source/WebKit/UIProcess/Cocoa/GPUProcessProxyCocoa.mm:
(WebKit::GPUProcessProxy::platformInitializeGPUProcessParameters):

Canonical link: https://commits.webkit.org/265610@main
@webkit-commit-queue
Copy link
Collaborator

Committed 265610@main (73df24e): https://commits.webkit.org/265610@main

Reviewed commits have been landed. Closing PR #15356 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 73df24e into WebKit:main Jun 29, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit2 Bugs relating to the WebKit2 API layer
Projects
None yet
6 participants