App (Toast) Notification Activation not supported on arm64
Describe the bug
On ARM64, when having the windows.toastNotificationActivation extension to the manifest, the app will crash when showing app notifications when running as a normal user. When running as an administrator, the app does not crash, but no toast notification will be shown.
See: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/notifications/app-notifications/app-notifications-quickstart?tabs=cs
Steps to reproduce the bug
- Use app notifications in the app, using this approach: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/notifications/app-notifications/app-notifications-quickstart?tabs=cs
- Try to show app notifications.
- AppNotificationManger.IsSupported() returns false
- Remove or show a notification using AppNotificationManager.Default instance.
- Crash when using as normal user / no notifications when running as administrator.
Example stack trace:
Expected behavior
Even when AppNotificationManger.IsSupported() returns false, showing a notifications still work on x64 on most systems. I expect this to be the case on arm64 as well.
Or at least, do not crash the app.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.4.5: 1.4.240411001
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
After looking at the code on the Windows App SDK repository, it is understandable why this "works" with admin right. That is because the manager basically just returns. AppNotifications are not supported when an application is elevated and AppNotificationManager.cpp line 105 shows this. The functions that do anything useful have a
if(!IsSupported())
{
return; //or some variation of this
}
at the start. The crash that is shown in the original post is coming from RemoveByTagAsync, and this should just exit when the application is elevated.
As I mentioned in the previous thread, the x64 on ARM64 environment is quirky. The biggest quirk is that x64 applications actually load the ARM64 libraries. These are built using the ARM64X format, and contain the native ARM64 binary as well as the ARM64EC symbols that an x64 application is able to call. I'm wondering if the ARM64 binaries provided by the Windows App SDK are ARM64 only and not ARM64X. Does the debugger show what library it is trying to load when it fails?
Thank you again @DarranRowe. I now see why there is no crash when the application is elevated... Good to know that running elevated effectively switches off all app notification code.
The debugger does not mention arm64x as far as I can see (I am not very good at using WinDbg, so I do not really know what to look for)
Windows 10 Version 22631 MP (8 procs) Free ARM 64-bit (AArch64) Product: WinNt, suite: SingleUserTS Personal Edition build lab: 22621.1.arm64fre.ni_release.220506-1250
IMAGE_NAME: Microsoft.Internal.FrameworkUdk.System.dll
STACK_COMMAND: ~61s ; .cxr ; kb
FAILURE_BUCKET_ID: FAIL_FAST_GUARD_ICALL_CHECK_FAILURE_c0000409_Microsoft.Internal.FrameworkUdk.System.dll!winrt::impl::capture_to_IWpnPlatform,int_
OS_VERSION: 10.0.22621.1 BUILDLAB_STR: ni_release OSPLATFORM_TYPE: arm64
Anyway, I can see that arm64 emulation is quirky. Most things seems to work great, however. My main concern now is to see if I can find (or code) an alternative for app notifications. Better yet, it would be great if Microsoft could make app notifications work on arm64.
You could always try the functionality documented here. You should also be able to find the code on the Github repository easily enough. (C++ version too.) But I honestly think that this is an issue with the singleton package.
Hi @wbokkers , Can you confirm the Visual Studio Version? Are you using VS 2022 17.6 (LKG15) or VS 2022 17.8 (LKG16 ) or any other version?
Hi @anupriya13, I am not sure. I always use the latest version at every moment. Currently I do avoid using App Notifications and use my own in-app notification implementation. Users seem to like this more and notifications are easier detected, so I do not need the feature anymore.
can you please share this screenshot from your vs .. Help -> About Microsoft Visual Studio .
I can, but I am sure I updated VS since I submitted the issue.
Can you run on 17.9 and update if it's still crashing?
I don't use app notification anymore, so there is no code to test, but as soon I have time, I will check.
For the record, there's a minimum reproducible sample here, that has been tested with 17.9 and is still broken: https://github.com/stegru/NotificationTest
@will-velazquez yes, we are aware of this, and we are working on the fix. It's a compiler bug for ARM SV2 which was fixed for LKG 16+. I will update it here once it's fixed / backported.