macOS: replace deprecated Carbon foregrounding with post-wx AppKit activation#1817
Conversation
|
Thanks for the PR. I agree that removing VeraCrypt’s direct use of deprecated Process Manager APIs is desirable, but I don’t think this implementation is safe as-is. The new helper calls Also, wxWidgets 3.2.10 already handles the non-bundled app activation case internally after creating One factual note: with the current Xcode SDK, these Process Manager APIs are still declared, so the issue is deprecation warnings, not immediate SDK removal. Could you please revise the approach and include macOS runtime testing for:
|
| // removed from recent macOS SDKs. Ensure the shared application exists, | ||
| // make it a regular foreground app so it gets a Dock icon and menu bar, | ||
| // and bring it to the front. | ||
| [NSApplication sharedApplication]; |
There was a problem hiding this comment.
This creates/uses NSApplication before wxWidgets initializes the macOS GUI application. That is risky for VeraCrypt because wxOSX creates its own wxNSApplication subclass during DoInitGui to handle Cocoa events correctly, including command-key key-up handling. If a plain NSApplication singleton is created here first, wxWidgets cannot later replace it with wxNSApplication.
Please rework this so VeraCrypt does not create NSApplication before wxWidgets initialization. A safer direction is to remove the pre-wx Carbon foregrounding block and rely on wxWidgets existing macOS activation path, or otherwise ensure wxNSApplication is created first.
| // Modern replacement for the deprecated Carbon Process Manager calls | ||
| // (GetCurrentProcess / TransformProcessType / SetFrontProcess), which are | ||
| // removed from recent macOS SDKs. Ensure the shared application exists, | ||
| // make it a regular foreground app so it gets a Dock icon and menu bar, | ||
| // and bring it to the front. |
There was a problem hiding this comment.
This rationale should be adjusted. In the current Xcode/macOS SDK I tested, GetCurrentProcess, SetFrontProcess, and TransformProcessType are still declared; GetCurrentProcess and SetFrontProcess produce deprecation warnings, but this is not currently an SDK-removal build break. The change should be framed as deprecation cleanup, not as replacing APIs that are already removed.
1b5f478 to
41b502d
Compare
|
Thanks, and good catches on both points. You're right that these APIs are only deprecated, not removed, on the current SDK — I've corrected the rationale to deprecation cleanup. I went with your first suggestion and removed the pre-wx Carbon foregrounding block entirely rather than adding a native helper, so nothing touches Rebased onto current master. Testing on arm64 (macOS 26.5): |
|
Built a signed |
|
Thanks for revising this. Removing the helper resolves the concern about creating On macOS 26.5.1 with wxWidgets 3.2.10 and a signed arm64 build, I invoked the inner executable from Terminal with a volume path. wxWidgets only activates an unbundled app or a bundled app with accessory policy. The inner executable still resolves to the enclosing Please activate the existing The PR title should also be updated since the current change removes the code rather than replacing it with |
…tivation The GUI entry point used deprecated Process Manager APIs to bring argument-bearing launches forward before wxWidgets initialized Cocoa. Removing the block alone leaves bundled inner-executable launches with regular policy but not necessarily frontmost, so command-line dialogs can open inactive. Remove the Carbon code and ApplicationServices include, then activate the existing NSApp from GraphicUserInterface::OnInit(), after wxWidgets creates wxNSApplication and before command-line processing. Preserve the previous argument semantics by acting only when wx filtered argc is greater than one; leading -psn_ and no-argument launches remain unchanged. Use -activate on macOS 14 and later, with -activateIgnoringOtherApps: as the macOS 12-13 fallback. Never create NSApplication or change its activation policy. Text mode remains outside this path.
41b502d to
933112d
Compare
|
Thanks for catching this. My earlier check treated I have amended the PR into one commit. Activation now occurs in Signed arm64 results on macOS 26.5.1 with wxWidgets 3.2.10 and deployment target 12:
The macOS 12-13 fallback is compile-verified but not runtime-tested on those releases. The PR title and description have also been corrected to describe deprecation cleanup and the post-wx lifecycle accurately. |
Summary
VeraCrypt brought argument-bearing macOS GUI launches to the foreground with the deprecated Carbon Process Manager APIs
GetCurrentProcess,TransformProcessType, andSetFrontProcess.Removing that block alone is insufficient for the bundled inner-executable case. The executable resolves to its enclosing
.appand already has regular activation policy, so wxWidgets does not run its unbundled/accessory activation path. The process can therefore be classified asForegroundwithout actually becoming frontmost, leaving command-line modal dialogs inactive.This change removes VeraCrypt's Carbon foregrounding and activates the existing wx-created
NSAppafter Cocoa initialization instead.Implementation
ApplicationServicesinclude fromMain.cpp.NSApp; it never callssharedApplicationand never changes activation policy.GraphicUserInterface::OnInit(), after wxWidgets has createdwxNSApplicationand beforeInit()or command-line processing can display modal UI.argc > 1. wxWidgets has already removed a leading-psn_, so Finder, LaunchServices, and no-argument launches retain their existing behavior.[NSApp activate]on macOS 14 and later, with compile-time and runtime availability guards andactivateIgnoringOtherApps:YESas the macOS 12-13 fallback.No public API or command-line interface changes are introduced.
Verification
Built a signed thin arm64 application with wxWidgets 3.2.10, SDK 26.5, and deployment target macOS 12.
git diff --checkpasses.--text --testpasses; debugger breakpoints on both AppKit activation selectors receive zero hits in text mode.-psn_launch, become frontmost normally.lsappinfo front, does not leaveLSWantsAttentionset, focuses the password field, and accepts keyboard input immediately.wxNSApplicationwith regular activation policy under LLDB. Cmd-key/menu behavior, Cmd+A in the password field, and Cmd+Q remain functional.--background-taskreturns success and exits immediately in both builds. The AppKit build did not briefly take focus in 10/10 trials, while the released Carbon build did in 10/10. The functional background-task behavior is unchanged; the short-lived, UI-less process exits before cooperative asynchronous activation becomes visible.The macOS 12-13
activateIgnoringOtherApps:branch is compile-verified but was not runtime-tested on those OS versions.