question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] WinUI statecontainer crashes app

See original GitHub issue

Is 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:closed
  • Created 10 months ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
brminnickcommented, Dec 5, 2022

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 to false:

XAML

mct:StateContainer.ShouldAnimateOnStateChange="False"

C#

StateContainer.SetShouldAnimateOnStateChange(myLayout, false);

Explanation

The TaskCanceledException is thrown when CurrentState changes before the fade animation has completed.

When ShouldAnimateOnStateChange == false, the SwitchToState() and SwitchToContent() methods run synchronously (eg They don’t need to await the fade animations). This means the methods always complete immediately and never throw a TaskCanceledException.

0reactions
MrDeejcommented, Mar 1, 2023

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found