maui
maui copied to clipboard
[Android] Fix Flickering issue when calling Navigation.PopAsync
Root Cause
The flickering during navigation occurred because, when performing PopAsync, the removed page’s handlers were set to null. This caused flickering as the navigation was processed.
Description of Change
The fix involves avoiding the removal of page handlers during PopAsync, which eliminates the flickering issue during navigation.
Issues Fixed
Fixes #13810
Validated the behaviour in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
Output Screenshot
Before
https://github.com/user-attachments/assets/d61c8903-d495-41bf-8ba6-3a4a0a5e716f
After
https://github.com/user-attachments/assets/1bba47ff-d1fd-4f4b-b740-9e1bd3ea00b3
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
Azure Pipelines successfully started running 3 pipeline(s).
It looks like the device tests on windows are crashing.
On CI you can check the logs here to see where it's crashing
This is the failing test NavigatedFiresAfterSwitchingFlyoutItems.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.Controls.IContentPresenterMethods.set_Content(IObjectReference _obj, Object value)
at Microsoft.UI.Xaml.Controls.ContentPresenter.set_Content(Object value)
at Microsoft.Maui.Platform.StackNavigationManager.OnNavigated(Object sender, NavigationEventArgs e)
at WinRT._EventSource_global__Microsoft_UI_Xaml_Navigation_NavigatedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, NavigationEventArgs e)
at ABI.Microsoft.UI.Xaml.Navigation.NavigatedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.Controls.IFrameMethods.GoBack(IObjectReference _obj, NavigationTransitionInfo transitionInfoOverride)
at Microsoft.UI.Xaml.Controls.Frame.GoBack(NavigationTransitionInfo transitionInfoOverride)
at Microsoft.Maui.Platform.StackNavigationManager.NavigateTo(NavigationRequest args)
at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.RequestNavigation(ShellSectionHandler handler, IStackNavigation view, Object arg3)
at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0.<Add>b__0(IElementHandler h, IElement v, Object o)
at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args)
at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args)
at Microsoft.Maui.Controls.ShellSection.Microsoft.Maui.IStackNavigation.RequestNavigation(NavigationRequest eventArgs)
at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SyncNavigationStack(Boolean animated, NavigationRequestedEventArgs e)
at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.OnNavigationRequested(Object sender, NavigationRequestedEventArgs e)
at Microsoft.Maui.Controls.ShellSection.InvokeNavigationRequest(NavigationRequestedEventArgs args)
at Microsoft.Maui.Controls.ShellSection.OnPopAsync(Boolean animated)
at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
at Microsoft.Maui.DeviceTests.ShellTests.<>c__DisplayClass32_0.<<NavigatedFiresAfterSwitchingFlyoutItems>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_1`1.<<CreateHandlerAndAddToWindow>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_0`1.<<CreateHandlerAndAddToWindow>
It looks like the device tests on windows are crashing. On CI you can check the logs here to see where it's crashing
This is the failing test NavigatedFiresAfterSwitchingFlyoutItems.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr) at ABI.Microsoft.UI.Xaml.Controls.IContentPresenterMethods.set_Content(IObjectReference _obj, Object value) at Microsoft.UI.Xaml.Controls.ContentPresenter.set_Content(Object value) at Microsoft.Maui.Platform.StackNavigationManager.OnNavigated(Object sender, NavigationEventArgs e) at WinRT._EventSource_global__Microsoft_UI_Xaml_Navigation_NavigatedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, NavigationEventArgs e) at ABI.Microsoft.UI.Xaml.Navigation.NavigatedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e) --- End of stack trace from previous location --- at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr) at ABI.Microsoft.UI.Xaml.Controls.IFrameMethods.GoBack(IObjectReference _obj, NavigationTransitionInfo transitionInfoOverride) at Microsoft.UI.Xaml.Controls.Frame.GoBack(NavigationTransitionInfo transitionInfoOverride) at Microsoft.Maui.Platform.StackNavigationManager.NavigateTo(NavigationRequest args) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.RequestNavigation(ShellSectionHandler handler, IStackNavigation view, Object arg3) at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0.<Add>b__0(IElementHandler h, IElement v, Object o) at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args) at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args) at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args) at Microsoft.Maui.Controls.ShellSection.Microsoft.Maui.IStackNavigation.RequestNavigation(NavigationRequest eventArgs) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SyncNavigationStack(Boolean animated, NavigationRequestedEventArgs e) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.OnNavigationRequested(Object sender, NavigationRequestedEventArgs e) at Microsoft.Maui.Controls.ShellSection.InvokeNavigationRequest(NavigationRequestedEventArgs args) at Microsoft.Maui.Controls.ShellSection.OnPopAsync(Boolean animated) at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping) at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest) at Microsoft.Maui.DeviceTests.ShellTests.<>c__DisplayClass32_0.<<NavigatedFiresAfterSwitchingFlyoutItems>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_1`1.<<CreateHandlerAndAddToWindow>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_0`1.<<CreateHandlerAndAddToWindow>
We'll run the DeviceTests using NET9 and provide an update.
will this ptach be merged into dotnet 8 maui?
@ygl-rg I think at this point with .NET 9 being close to being released this will be .NET 9 only
It looks like the device tests on windows are crashing. On CI you can check the logs here to see where it's crashing
This is the failing test NavigatedFiresAfterSwitchingFlyoutItems.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr) at ABI.Microsoft.UI.Xaml.Controls.IContentPresenterMethods.set_Content(IObjectReference _obj, Object value) at Microsoft.UI.Xaml.Controls.ContentPresenter.set_Content(Object value) at Microsoft.Maui.Platform.StackNavigationManager.OnNavigated(Object sender, NavigationEventArgs e) at WinRT._EventSource_global__Microsoft_UI_Xaml_Navigation_NavigatedEventHandler.EventState.<GetEventInvoke>b__1_0(Object sender, NavigationEventArgs e) at ABI.Microsoft.UI.Xaml.Navigation.NavigatedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e) --- End of stack trace from previous location --- at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr) at ABI.Microsoft.UI.Xaml.Controls.IFrameMethods.GoBack(IObjectReference _obj, NavigationTransitionInfo transitionInfoOverride) at Microsoft.UI.Xaml.Controls.Frame.GoBack(NavigationTransitionInfo transitionInfoOverride) at Microsoft.Maui.Platform.StackNavigationManager.NavigateTo(NavigationRequest args) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.RequestNavigation(ShellSectionHandler handler, IStackNavigation view, Object arg3) at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0.<Add>b__0(IElementHandler h, IElement v, Object o) at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args) at Microsoft.Maui.CommandMapper.Invoke(IElementHandler viewHandler, IElement virtualView, String property, Object args) at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args) at Microsoft.Maui.Controls.ShellSection.Microsoft.Maui.IStackNavigation.RequestNavigation(NavigationRequest eventArgs) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SyncNavigationStack(Boolean animated, NavigationRequestedEventArgs e) at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.OnNavigationRequested(Object sender, NavigationRequestedEventArgs e) at Microsoft.Maui.Controls.ShellSection.InvokeNavigationRequest(NavigationRequestedEventArgs args) at Microsoft.Maui.Controls.ShellSection.OnPopAsync(Boolean animated) at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping) at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest) at Microsoft.Maui.DeviceTests.ShellTests.<>c__DisplayClass32_0.<<NavigatedFiresAfterSwitchingFlyoutItems>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_1`1.<<CreateHandlerAndAddToWindow>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass30_0`1.<<SetupWindowForTests>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass3_0.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.Dispatching.DispatcherExtensions.<>c__DisplayClass2_0`1.<<DispatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Maui.DeviceTests.ControlsHandlerTestBase.<>c__DisplayClass16_0`1.<<CreateHandlerAndAddToWindow>We'll run the DeviceTests using NET9 and provide an update.
I ran the device tests using the latest MAUI source with our fix and confirmed that the mentioned test passed successfully. Let me know if you have any concerns.
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
Could review the failing test?
I reviewed the failing test case by running it on our machine, and it seems to be running fine.
Can you move the
PoppingFlyoutPageDoesntCrashtest to Appium from the Device Tests?
I have moved the specified test case to Appium. Could you please review it and let me know if you have any concerns?
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
Azure Pipelines successfully started running 3 pipeline(s).
/rebase
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
