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

fix macos crash at startup by not parsing all app arguments into uris. #14494

Merged
merged 2 commits into from Feb 5, 2024

Conversation

danwalmsley
Copy link
Member

@danwalmsley danwalmsley commented Feb 5, 2024

  • Fixes the crash when Avalonia starts up on macOS with arguments.

This was caused due to the "FilesOpened" callback being unexpectedly raised for all command line arguments.

The recent PR #14106 implemented a Uri protocol raised event, where the data was parsed into a uri.

Its not possible to do this for all arguments.

This PR does the following:

  • Separate the macOS backend callbacks (void)application:(NSApplication *)sender openFiles and (void)application:(NSApplication *)application openURLs into 2 separate callbacks in our backend (previously they were the same)

  • Continue raising the legacy RaiseUrlsOpened codepath from the FilesOpened (as has worked for many years), to not break previous behaviour.

  • Only raise the new uri handling code from the openURLS macOS callback, and use Uri.TryCreate ().

This fixes the bug and ensures the old behaviour.

Fixes #14411

@@ -13,12 +13,21 @@ internal class AvaloniaNativeApplicationPlatform : NativeCallbackBase, IAvnAppli
void IAvnApplicationEvents.FilesOpened(IAvnStringArray urls)
{
Copy link
Member

Choose a reason for hiding this comment

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

This method is never really executed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

still executed to maintain legacy behaviour, but it wont call the new uri api codepath from here.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044450-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@danwalmsley danwalmsley added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Feb 5, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044456-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 merged commit 6513f71 into master Feb 5, 2024
7 checks passed
@maxkatz6 maxkatz6 deleted the fixes/macos-url-handling branch February 5, 2024 21:11
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Feb 8, 2024
nift4 added a commit to nift4/GalaxyBudsClient that referenced this pull request Feb 10, 2024
We need this fix for macOS: AvaloniaUI/Avalonia#14494
because when reopening an already-open app from finder, it calls openURLs
which crashes in 11.0.7
but Linux/X11 requires 11.0.7 or unreleased version for working menus
so do just use the proper CI build instead of waiting for Avalonia
to make a new release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App crashes immediately on Startup on Mac OS if any arguments are passed (11.0.7)
3 participants