sparkle-project / Sparkle

A software update framework for macOS
https://sparkle-project.org
Other
7.37k stars 1.05k forks source link

Immediate crashing of notarized menu bar app after launching #2600

Closed nilekell closed 1 month ago

nilekell commented 1 month ago

I am developing a macos menu bar app, and for some reason, when I archive, notarize & export the app to my Applications folder and run the app, it crashes instantly. When I use the Console app, I see the following error messages:

myapp[30188]: AppSandbox request successful

Channel could not return listener port.

activating connection: mach=false listener=false peer=false name=com.apple.hiservices-xpcservice

activating connection: mach=true listener=false peer=false name=com.apple.window_proxies

invalidated because the current process cancelled the connection by calling xpc_connection_cancel()

[app<application.com.myapp.15235459.15235465(501)>:30188] termination reported by launchd (2, 5, 5)

failed to fetch /Applications/myapp.app/Contents/_CodeSignature/CodeRequirements-1 error=-10

failed to get text offset for /Applications/myapp.app/Contents/MacOS/myapp[30188]: (#3) No such process

RBSStateCapture remove item called for untracked item 378-345-52811 (target:[app<application.com.myapp.15235459.15235465(501)>:30188])

When I run the app in Xcode (in debug mode & release mode), there are no Warning messages except this one for Sparkle (I am relatively sure it is unrelated to my issue but including here for brevity):

Warning: Background app automatically schedules for update checks but does not implement gentle reminders. As a result, users may not take notice to update alerts that show up in the background. Please visit https://sparkle-project.org/documentation/gentle-reminders for more information. This warning will only be logged once.

I have tried the following to stop the app from crashing, all to no avail:

- Clean Xcode
- Delete Xcode Derived Data
- Restart Mac
- Build app with an alternative bundle identifier
- Removed Sparkle package and re-archived, notarized app
- Enable App Sandbox in Xcode Project > Target > Signing
- Added com.apple.security.automation.apple-events to app entitlements file
- Replaced the 'Developer ID Application Certificate' from Keychain with a newly generated certificate
- Use Xcode Manual Signing instead of automatic. (Create dev, release provisioning profiles, app id)

Additional context

Xcode 15.2
MacOS Sonoma 14.5
Xcode minimum deployment: 13.0

Do you use Sandboxing in your app?

Yes

Version of Sparkle.framework in the latest version of your app

2.6.3

Version of Sparkle.framework in the old version of app that your users have (or N/A)

N/A

Sparkle's output from Console.app

Warning: Background app automatically schedules for update checks but does not implement gentle reminders. As a result, users may not take notice to update alerts that show up in the background. Please visit https://sparkle-project.org/documentation/gentle-reminders for more information. This warning will only be logged once.

Steps to reproduce the behavior

  1. Download the App binary.

  2. Move the app to the Applications folder and run the app.

  3. The app will crash immediately appearing as if you never attempted to run the app. To view the logs I pasted at the top of this issue, you can open the 'Console' app > Window > Action > Include Info, Debug messages > Search filter for app name: 'Ocheeflow'.

zorgiepoo commented 1 month ago

Please symbolicate your crash log or enable debug info when running your app outside of Xcode, and find the line of code / backtrace that is responsible for it crashing from your crash report.

There are no indications this crash is related to Sparkle at all. It looks like a crash in your app's code, maybe from a Swift force unwrap or a failure assertion or what not. If there is anything here that is actionable on Sparkle's end, I will re-open.

nilekell commented 1 month ago

There are no logs when I enable debug info and run the app outside of xcode.

zorgiepoo commented 1 month ago

When an app crashes and is not attached to the debugger the OS generates a crash report. You have that crash report if you look in the Crash Report section of the Console app. If you don’t compile the binary with debug symbols embedded you’ll have to symbolicate the crash report with your external dSYM debug symbols (look this up). You are focusing too much on log messages when you should be focusing on the crash report which will tell you why the app crashed, including the thread that crashed, its backtrace, and the specific file/line of code (after symbolication) causing the crash.

nilekell commented 1 month ago

Ok thank you. I have identified the crash report in Console app, and getting the typical

Unexpectedly found nil while unwrapping an Optional value
zorgiepoo commented 1 month ago

Should also be able to identify the line of code in your app triggering that if you haven’t found out already.

nilekell commented 1 month ago

Thank you, yes I have found the issue and its unrelated to Sparkle. It was down to the fact that I thought environment variables from the scheme are injected into release builds outside of xcode, when they are not.