Skip to content
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

[Android] Fix Flickering issue when calling Navigation.PopAsync #24887

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Sep 24, 2024

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

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before

366413807-f0592d6d-6b89-48b0-bab8-eed46d20336c.mp4

After

366413828-b47e24f4-68f0-44a0-b1bf-ed8dd24d1dcf.mp4

@devanathan-vaithiyanathan devanathan-vaithiyanathan changed the title changes added [Android] Fix Flickering issue when calling Navigation.PopAsync Sep 24, 2024
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 24, 2024
@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review September 24, 2024 07:50
@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho rmarinho self-requested a review September 24, 2024 18:04
Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems is making the Windows Device tests fail , I run few times and got same results. Maybe this is causing some side effects on Windows. But maybe also rebase just to make sure branch is updated with latest .

@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

PureWeen commented Sep 25, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the device tests on windows are crashing.

On CI you can check the logs here to see where it's crashing

image

@jsuarezruiz
Copy link
Contributor

It looks like the device tests on windows are crashing.

On CI you can check the logs here to see where it's crashing

image

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>

@devanathan-vaithiyanathan
Copy link
Contributor Author

It looks like the device tests on windows are crashing.
On CI you can check the logs here to see where it's crashing
image

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.

@ygl-rg
Copy link

ygl-rg commented Oct 17, 2024

will this ptach be merged into dotnet 8 maui?

@jfversluis
Copy link
Member

@ygl-rg I think at this point with .NET 9 being close to being released this will be .NET 9 only

@devanathan-vaithiyanathan devanathan-vaithiyanathan changed the base branch from net9.0 to main October 22, 2024 09:30
@devanathan-vaithiyanathan
Copy link
Contributor Author

It looks like the device tests on windows are crashing.
On CI you can check the logs here to see where it's crashing
image

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.

@devanathan-vaithiyanathan
Copy link
Contributor Author

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a device test failing related with pop navigating.
image

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could review the failing test?

@devanathan-vaithiyanathan
Copy link
Contributor Author

Could review the failing test?

I reviewed the failing test case by running it on our machine, and it seems to be running fine.

@PureWeen PureWeen added this to the .NET 9 Servicing milestone Oct 31, 2024
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the PoppingFlyoutPageDoesntCrash test to Appium from the Device Tests?

@Vignesh-SF3580
Copy link
Contributor

Can you move the PoppingFlyoutPageDoesntCrash test 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?

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution
Projects
Status: Changes Requested
Development

Successfully merging this pull request may close these issues.

Flickering when calling Navigation.PopAsync(false).
8 participants