-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
WinRt exception when page navigated #22790
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
Hi @davide-cavallini, I can't open your sample link. Can you reattach the sample to help us reproduce the error? Thank you for your patience. |
Hi @jaosnz-rep. |
We're experiencing a similiar issue only on windows when navigating back via Shell.Current.GoToAsync(".."). Sometimes it takes 20 navigations back and forth, sometimes five. Stacktrace ends with System.Runtime.InteropServices.COMException without any message. |
We have experienced this and came up with a workaround. The initial fix was creating our own StackNavigationManager that would navigate with Polly retries with just repeating the setting of the page's content, if that fails then the process is repeated with a new mauicontext. `internal sealed class ExtendedNavigationViewHandler : NavigationViewHandler
}` To use this handler, register it builder.ConfigureMauiHandlers(handlers => handlers.AddHandler<NavigationPage, ExtendedNavigationViewHandler>()); If there are others just chain the call. `/// /// Delete after this is done microsoft/microsoft-ui-xaml#9070 /// Default for and in WinUI is true and for MAUI it also defaults to true. /// private static void DisableTextServices() { // the discarded action calls UpdateIsSpellCheckEnabled but to protect ourselves from future modification in that corresponding action we call it manually EditorHandler.Mapper.ModifyMapping(nameof(IEditor.IsSpellCheckEnabled), (handler, editor, _) => { ((InputView)editor).IsSpellCheckEnabled = false; ((InputView)editor).IsTextPredictionEnabled = false; handler.PlatformView?.UpdateIsSpellCheckEnabled(editor); });
}` With these two in place the random crashes are gone. But we still get some crashes from our customers where the stacktrace is just COMException without anything relevant to pinpoint the crash place. We suspect that it is due to some memory leaks from CsWinRT, WinUI3 and MAUI but we are not sure because we can not reproduce these crashes in our environment even with restricted VMs. |
@qjustfeelitp thanks for your workaround! We also struggled with this issue and implemented something similar. But let's be honest it is terrible that we have to do something like that :( Could you please elaborate on this: If I understood correctly, you had this issue even during initial navigation? Because our case is mostly bounded to back navigation and we didn't have to set XamlRoot again and use platform view with new MauiContext. Just re-setting presenter's content solved the issue. Maybe we missed something crucial here? |
We encounter this issue occasionally as well, and it can be quite frustrating. |
If it can be useful information, another way to mitigate the frequency of error (please note, mitigate, not avoid) is to place a little delay before navigating: Task.Delay(300) or Task.Sleep() Catching the exception is possibile, but at that point navigation no longer works and you need to kill and restart app. |
If anyone can provide a more consistent repro, exception, or possibly a stack dump when the exception happens that would be helpful. |
Can't really share my repo, but will try to isolate it in a new repo in the coming days. Normally it takes between 5-20 navigations back and forth between pages but it will definitely crash after some time. We're using Sentry (and AppCenter) to log our crashes in prod and all windows devices (does not matter if win10 or win11) have daily crashes with the same exception. In debug two unhandled exceptions will occour before the app crashes:
Second exception after that:
Then the app will crash/close. I have saved two memory dumps but they are pretty big (each one 600mb) and I'm not too keen to share them in public, as they'll probably contain some internal info. |
@PureWeen Here is memory dump https://fileport.io/3mCwzcmFgatG I updated the code to automate the navigation https://github.com/qjustfeelitp/maui-22790-repro I don't think that it is tied to your machine, mine is beefy enough: Procesor 12th Gen Intel(R) Core(TM) i9-12900 with 64 gigs of RAM If you need more information, please don't hesitate to be specific. |
Looks like the dmp file was taken down -- could you please email it to me (the exception is a stowed exception, so it's not possible to tell what the "real" one is from the stack trace...)? mikecorsaro at microsoft. Thanks! Testing your automated example -- it doesn't actually seem to crash on the latest "main" branch. I don't think anything was fixed related to it but have you had the chance to try it there? |
This issue just happened also to me, the Windows app uses Maui 8.0.40 and I was doing a back navigation with There is a first unhandled exception with empty text in Exception field and the following text in Message field: Then a second exception is thrown:
After that, the same back navigation does not work anymore, but it's possible to successfully navigate to another page by clicking a Shell FlyoutItem, then the navigation seems to restart working as before. |
Looks like this might be the actual cause: microsoft/CsWinRT#1834 |
We've started getting loads of failures when doing some specific navigation events in our app after upgrading to .net9. error we get is still failing in .net9 sr1 release |
@Foda is there a CI build with these changes? if so, what is its version? |
for the sake of correctness, I can now say that the issue I mentioned above is caused by UraniumUI and its InputKit.Maui dependency, not directly related with maui. but something may have changed in maui .net9 that prompted this to start failing, as we had this package in place for a long while and only now it started failing. |
Description
When the app navigate between two pages randomly crashes.
In the second page my app is trying to deserialize a json file to runtime create the UI.
Steps to Reproduce
To speed up the process I've used a tool for automatic clicking ([https://tinytask.net/download.html])
Link to public reproduction project repository
https://github.com/davide-cavallini/WinRtExceptionTest
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
No response
Did you find any workaround?
Didn't find a specific workaround, but calling Task.Sleep(n) before navigation seems to reduce the frequency of exception happening.
Relevant log output
The text was updated successfully, but these errors were encountered: