Skip to content

Commit 6e3e422

Browse files
committed
darwin: stop calling SetApplicationIsDaemon()
It's been reported that calling this function causes the Core Graphics framework to start reporting bogus values. Commit 565cdd1 ('Revert "darwin: speed up uv_set_process_title()"') attempted to fix this but apparently merely postponed the moment when `CGDisplayPixelsWide()` and friends start reporting bogus values. The Chromium code base mentions that calling `SetApplicationIsDaemon()` prevents the HIServices framework from terminating the process when it can't connect to launchservicesd. Libuv itself doesn't use HIServices but it's possible that the libuv user does. If said user doesn't call `SetApplicationIsDaemon()`, it's possible this commit introduces an observable change in behavior. The `SetApplicationIsDaemon()` call was introduced in commit 08e0e63 ("darwin: avoid calling GetCurrentProcess") from October 2013 to work around a bug in macos 10.9 where the Activity Monitor showed the program as "Not responding." Fixes: #2566 (for real, hopefully) Fixes: nodejs/node#31328 PR-URL: #2593 Refs: https://cs.chromium.org/chromium/src/sandbox/mac/system_services.cc?l=26&rcl=a06d2fe5a279ddecd358d919d461080e2c53c92e Reviewed-By: Colin Ihrig <[email protected]>
1 parent 64e5a65 commit 6e3e422

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/unix/darwin-proctitle.c

+9-18
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ int uv__set_process_title(const char* title) {
7272
CFStringRef* display_name_key;
7373
CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
7474
CFBundleRef (*pCFBundleGetMainBundle)(void);
75-
CFBundleRef hi_services_bundle;
76-
OSStatus (*pSetApplicationIsDaemon)(int);
7775
CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
7876
void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
7977
void*);
@@ -144,30 +142,19 @@ int uv__set_process_title(const char* title) {
144142
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
145143
goto out;
146144

147-
/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
148-
hi_services_bundle =
149-
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
150-
err = UV_ENOENT;
151-
if (hi_services_bundle == NULL)
152-
goto out;
153-
154-
*(void **)(&pSetApplicationIsDaemon) = pCFBundleGetFunctionPointerForName(
155-
hi_services_bundle,
156-
S("SetApplicationIsDaemon"));
157145
*(void **)(&pLSApplicationCheckIn) = pCFBundleGetFunctionPointerForName(
158146
launch_services_bundle,
159147
S("_LSApplicationCheckIn"));
148+
149+
if (pLSApplicationCheckIn == NULL)
150+
goto out;
151+
160152
*(void **)(&pLSSetApplicationLaunchServicesServerConnectionStatus) =
161153
pCFBundleGetFunctionPointerForName(
162154
launch_services_bundle,
163155
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
164-
if (pSetApplicationIsDaemon == NULL ||
165-
pLSApplicationCheckIn == NULL ||
166-
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
167-
goto out;
168-
}
169156

170-
if (pSetApplicationIsDaemon(1) != noErr)
157+
if (pLSSetApplicationLaunchServicesServerConnectionStatus == NULL)
171158
goto out;
172159

173160
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
@@ -178,6 +165,10 @@ int uv__set_process_title(const char* title) {
178165

179166
asn = pLSGetCurrentApplicationASN();
180167

168+
err = UV_EBUSY;
169+
if (asn == NULL)
170+
goto out;
171+
181172
err = UV_EINVAL;
182173
if (pLSSetApplicationInformationItem(-2, /* Magic value. */
183174
asn,

0 commit comments

Comments
 (0)