[BUG] WinUI statecontainer crashes app
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current Behavior
If you click too fast on the statecontainer change state button in sample, the app crashes due to task cancellation beeing thrown to cancel the state changing task
Expected Behavior
It should just cancel the state change task. Without an exception
Steps To Reproduce
Open windows Navigate to statecontainer Click any state changing button fast enough that a new state is requested before the current state is finished with transitioning.
App hard crash happens in windows, due to WinUI missing a global unhandled exception for async tasks (they have for voids though)
Link to public reproduction project repository
Use the sample app in this repo
Environment
- .NET MAUI CommunityToolkit:
- OS:
- .NET MAUI:
All environments and version of Maui which creates a WinUI application
Anything else?
I can fix this
Issue Analytics
- State:
- Created 10 months ago
- Comments:17
Top Results From Across the Web
[BUG] StateContainer crash app when state change too fast
I have read the "Reporting a bug" section on Contributing file. Current Behavior. I am currently testing the state container on WinUI and ......
Read more >WinUI 3 app crashed when deployed to the store
I have a WinUI 3 App that recently crashed when I install it via the Windows Store. ... The error message in the...
Read more >WINUI 3 App Crash in Idle Time
kindly, please support us as we are facing an Issue on one of our developed application as the Application always crash during Idle...
Read more >App Crashing in IOS : r/dotnetMAUI
Created a app using .NET MAUI works fine in the Android but those same build is continuously crashing in IOS, not getting the...
Read more >XAML Controls Gallery crashes with unhandled Win32 ...
However my application and Xaml Controls Gallery crashes every time on startup. Steps to reproduce the bug. Steps to reproduce the behavior:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m still looking into the best way to resolve this Issue, but wanted to share a workaround for anyone experiencing this problem in the meantime:
Workaround
Set
ShouldAnimateOnStateChange
tofalse
:XAML
C#
Explanation
The
TaskCanceledException
is thrown whenCurrentState
changes before the fade animation has completed.When
ShouldAnimateOnStateChange == false
, theSwitchToState()
andSwitchToContent()
methods run synchronously (eg They don’t need toawait
the fade animations). This means the methods always complete immediately and never throw aTaskCanceledException
.Yes, it seems like you have addressed the “we will crash your windows app feature” of changing states when statecontainer is in the process of a previous change.
Good 😃