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

Bug: When using WindowsEx class, closed application crashes on launch when activated from notification. #115

Closed
nik9play opened this issue Mar 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@nik9play
Copy link

If there is a WindowEx window in the project, the application that is not running crashes when the notification is clicked and also when the application is started with the argument ----AppNotificationActivated:.

When Native Code Debugging is enabled it gets me there:
изображение

Seems like m_activatedEventArgs and m_waitHandleForArgs are null.

Looks like the window object does not even have to be created for the bug to happen. This happens in packaged in unpackaged modes.

I'm also created issue in WinAppSDK repo (microsoft/WindowsAppSDK#3535) before I knew about the WindowEx bug.

@nik9play
Copy link
Author

nik9play commented Mar 25, 2023

I think I've found the problem. When WebAuthenticator is initialized, it gets activated arguments:

изображение

However, as stated in the Microsoft docs (https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/notifications/app-notifications/app-notifications-quickstart?tabs=cs#step-3-register-to-handle-an-app-notification), you cannot call GetActivatedEventArgs() before the AppNotificationManager is registered. If OnAppCreation is commented out in the Init method, everything works fine.

Maybe we should make WebAuthenticator initialization optional or manual?

@dotMorten dotMorten added the bug Something isn't working label Apr 13, 2023
@dotMorten
Copy link
Owner

dotMorten commented Apr 13, 2023

You cannot call GetActivatedEventArgs() before the AppNotificationManager is registered.

According to https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.appinstance.getactivatedeventargs?view=winrt-22621 you can call it before even App.xaml gets called and samples shows it called in the main method:

image

I think the above statement only applies if you use app notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants