Closed mjo151 closed 2 months ago
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
any updates on this? Facing same issue with a very simple flyout behaviour.
Error probably not fixed as written just above.
After changing the orientation of the tablet, exactly the same error occurs (same stack but with different line numbers)
I've created a minimal MAUI 8.0.80 app with a Flyoutpage. All test are done on a physical tablet. To reproduce the problem, just switch from landscape to portrait, and from portrait to landscape. And repeat until the crash occurs. Sometime the crash occurs immediately, sometime after a dozen of rotations. It seems related to the speed of the rotation. Sometime, in landscape mode, the split mode does not appear. And at the next rotation back from portrait, it will appear again. The crash occurs when rotating from portrait to landscape. It seems to be consistent with the cast exception. The panel layout is already a linear panel and the android native code seems to handle at this time the popover panel.
When considering the FlyoutPageRenderer of Xamarin (was working perfectly) https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.Android/AppCompat/FlyoutPageRenderer.cs I notice in the code 2 hacks with await Task.Delay(100);
There is no such code in the MAUI FlyoutViewHandler https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs
I don't know if it is related.
The reality however is that it is impossible to release an app on a tablet that crashes when you change the orientation.
After investigations, it appears the root cause of this problem is in Maui-main\src\Essentials\src\DeviceDisplay\DeviceDisplay.android.cs
public override async void OnOrientationChanged(int orientation)
{
await Task.Delay(500);
onChanged();
}
The code is awaiting half a second (why so long?) but if in the interval another rotation occurs, the FlyoutPage enter in race conditions.
This is not an acceptable solution but if I replace OnOrientationChanged by this code, the error does not occur anymore. And it solves other errors like split mode visible in portrait.
private bool changeIsBusy;
public override async void OnOrientationChanged(int orientation)
{
if (!changeIsBusy)
{
try
{
changeIsBusy = true;
await Task.Delay(500);
onChanged();
}
finally
{
changeIsBusy = false;
}
}
}
Hoping this will help someone to provide a real solution.
Will this make it to SR9?
Temporary fix https://gist.github.com/guyvaio/5ca11a6aa373c1fe486cc9e25137aeec Hope this helps others.
Why is this issue closed? I see no open issue addressing it. The crash is rather easy to reproduce with latest MAUI. The workaround by @guyvaio sadly didn't fix it for us either.. :(
I am also still experiencing this issue on an Android tablet using the latest .NET 8 and 8.0.82 maui compatibility packages.
Description
Toggling the FlyoutLayoutBehavior property on a Flyout page on Android causes the app to crash. The problem occurs in .NET 8 SR1 and SR2, and this problem also existed in .NET 7.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/mjo151/maui-flyout-behavior-bug
Version with bug
8.0.0-rc.1.9171
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13 (did not test other Android versions)
Did you find any workaround?
I did not find a workaround for this issue.
Relevant log output