[Android] Fix: Modal Animation Repeats When Returning from Background#28538
[Android] Fix: Modal Animation Repeats When Returning from Background#28538bhavanesh2001 wants to merge 7 commits intodotnet:mainfrom
Conversation
|
Hey there @bhavanesh2001! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
jsuarezruiz
left a comment
There was a problem hiding this comment.
Could include an UITest like
https://github.com/user-attachments/assets/bf28a45f-dcde-4b26-bdb3-1342dc9d4a3c
?
In the test, can use:
App.BackgroundApp();
App.ForegroundApp();
To move the App to background etc.
|
@jsuarezruiz Would it be possible to include a UI test for this? Since the issue is that the modal animation replays when returning from the background, how can we verify in an automated test that the animation has not been triggered again? |
src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Android.cs
Show resolved
Hide resolved
|
I think GenericGlobalLayoutListener will cause memory leaks |
|
IMO the animation should start in the
|
|
@kubaflo I get that |
@kubaflo I’ve added a memory leak test for when a modal is opened with animation, and it passes with the GenericGlobalLayoutListener implementation. device_test.mov@jsuarezruiz could you run pipelines on this? |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@jsuarezruiz fixed failing tests. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
f3b93c5 to
7581ea9
Compare
src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Android.cs
Show resolved
Hide resolved
|
PureWeen
left a comment
There was a problem hiding this comment.
I'd like to iterate on this path first
https://github.com/dotnet/maui/tree/modal_window_anim
See if this just naturally works
|
closing in favor of #29557 |


Description of Change
This PR provides a fix for #28492 and is an alternative to #28522. It ensures that modal animations only play once when the modal is first displayed and do not replay when the app returns from the background.
Rather than starting the animation in
OnStart(),this fix attaches aGlobalLayoutListenerto the view insideOnCreateView(). When the view's layout is complete for the first time, the listener invokes the animation and then removes itself to prevent any further invocations. Additionally, theOnAnimationEndedmethod has been moved out of the lambda for improved readability.After Fix:
fix.mov
Issues Fixed
Fixes #28492
Related PR #28522