-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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? |
I came up with this workaround 6 months ago and if I remember correctly I put it there only as a fallback if the first retry group fails and setting the new MauiContext helped. The crashes are bound to back navigation but sometimes it also crashes after navigating back and to some other place. Yes, it is not superb having to dig in Maui and look for workarounds, we have quite a lot of them, especially for WinUI3. |
I'm having a bit of difficulty reproducing this, even with automated tooling. Sorry -- do y'all have a better example? |
Hi @Foda I am a colleague of Davide who will be away for a few days. I tried to launch the example again and I still get the error. I did some tests with workloads for maui-windows for 8.0.7 and 8.0.72 on different machines (Win 10 and 11), debug and release: Used TinyTask for automating navigation (I used 2x speed). I get same exception. |
@ARLasersoft I'm pretty much unable to reproduce this on my machine without spending huge amounts of time on it. I've clicked "navigate to page 2" then back to the main page >1000 times without a crash. I also let the automated tool run for >20 mins without it occurring. Then, I randomly clicked a few times and it triggered. But since then I've been unable to reproduce it over the past 2 days... could you try and reproduce this in a plain WinUI app using the |
@Foda It's just a simple app as I could not get you our business app which is far more complex and this issue appeared more frequently, if you cannot reproduce it, relaunch the app and try again. Do you think this is enough? |
I believe it's not possible to reproduce this issue in a plain WinUI using Frame control, just because exception occurs when MAUI's StackNavigationManager tries to set content into the page presenter (and it's a good question what was the intense to implement navigation in this way):
Plain WinUI navigation approach with Frame control doesn't need this manipulation and works differently. |
@IvanStupak do you have an example of implementing it a different way? |
Our app crashes also every day because of this bug on Windows by just simple navigating between pages and the problem is there since the launch of MAUI |
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. |
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: