You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Popup V2 - Android - ShowPopupAsync(INavigation) returns a Task that never completes #2703
When I call ShowPopupAsync and then call CloseAsync() from inside my popup, the popup closes but ShowPopupAsync's task never completes so the result is never available.
Expected Behavior
I expect the task to complete when I close the popup.
Steps To Reproduce
Derive a popup from Popup<bool?>
Call OpenPopupAsync() on it, and close the popup from within using CloseAsync()
Thanks for looking into this @TheCodeTraveler , can you edit your test to actually return a DTO/value from the Popup? I've tried a lot different things but I just cannot get the task to return.
It's not 100%, but if you press the button and raise a popup, then light-dismiss it and don't see an immediate alert displayed, then you're seeing a repro. (Aside: I'm not quite sure why the popup isn't displaying its XAML and is just a little white box, but that's probably another story).
It's taken a lot of attempts but have seen it fail 2 times out of maybe 50 shows/closes. It doesn't feel any closer but let's hope I can find a way to reliably reproduce it
In my case it fails 45 out of 50 shows/closes. And even 1 failure means the user flow is interrupted, it has a huge impact. I have only tested on Android
OK, I think I have a winner. I added GC.Collect() calls before and after the call to CloseAsync() and I now have a 100% repro with and without hot reload and even without a debugger.
Pull my repro above to the latest
Run the MCT 2703 repro
Hit the close button in the popup ----> this is key; light-dismissing the popup generally works fine
@mfeingol excellent work! I can confirm that I can reproduce 100% of the time now.
I've had a Quick Look at our code and there is in fact a WeakEventManager instance for handling the popup close events. I might not be able to look at it today but it looks like we might need a stronger reference.
I think the first step will be to reproduce this in a unit test (which I hope should be straightforward given your investigation work) and then debug/fix it
Activity
Cristian-Azeta commentedon Jun 12, 2025
Example in Android ...
TestPage.xaml
TestPage.xaml.cs
TestPopup.xaml
TestPopup.xaml.cs
e0548965 commentedon Jun 13, 2025
Having the same issue, any workaround? Quite big issue for us after just completing the upgrade to v12.0.0
AlanHoiland commentedon Jun 13, 2025
I'm seeing the same issue. Doesn't happen every time, maybe 50%.
crwsolutions commentedon Jun 13, 2025
e0548965 commentedon Jun 13, 2025
Happens consistently for us every time
mfeingol commentedon Jun 13, 2025
Same here - happens every time.
bijington commentedon Jun 13, 2025
Perhaps one of you can provide a sample repository?
TheCodeTraveler commentedon Jun 13, 2025
TheCodeTraveler commentedon Jun 13, 2025
Hi gang!
Add Popup Tests
e0548965 commentedon Jun 13, 2025
Thanks for looking into this @TheCodeTraveler , can you edit your test to actually return a DTO/value from the Popup? I've tried a lot different things but I just cannot get the task to return.
I think this is the same issue: https://developercommunity.visualstudio.com/t/Popup-v2-in-CommunityToolkitMaui-1200/10921966?viewtype=all&space=21&ftype=problem&sort=newest
mfeingol commentedon Jun 16, 2025
@TheCodeTraveler:
Please give this a spin: https://github.com/mfeingol/repros/tree/master/CommunityToolkit_2703_repro
It's not 100%, but if you press the button and raise a popup, then light-dismiss it and don't see an immediate alert displayed, then you're seeing a repro. (Aside: I'm not quite sure why the popup isn't displaying its XAML and is just a little white box, but that's probably another story).
25 remaining items
stefanbogaard86 commentedon Jun 20, 2025
Hello @bijington, the debugger attached seems to make it worse, but it also occurs in release builds.
bijington commentedon Jun 20, 2025
It's taken a lot of attempts but have seen it fail 2 times out of maybe 50 shows/closes. It doesn't feel any closer but let's hope I can find a way to reliably reproduce it
FrederikFBrandt commentedon Jun 20, 2025
In my case it fails 45 out of 50 shows/closes. And even 1 failure means the user flow is interrupted, it has a huge impact. I have only tested on Android
bijington commentedon Jun 20, 2025
I don't think we are questioning the impact but we are questioning our ability to reproduce the issue.
What development environment are you using?
The sooner we get to a set of reliably reproducible steps the easier this is going to be to fix.
Also are you testing against the supplied sample repository or your own application?
mfeingol commentedon Jun 20, 2025
@bijington:
I'm using Windows 11, VS 2022 [latest], and an Android emulator running Android 15 with 4GB of RAM.
I played with disabling .NET and XAML hot reload and observed the following:
I'm not sure I understand the pattern here, but hot reload does seem to be required for the repro timing.
Question - is there a weak reference in here somewhere that might be causing this if the GC were to run more aggressively?
mfeingol commentedon Jun 20, 2025
@bijington:
OK, I think I have a winner. I added GC.Collect() calls before and after the call to CloseAsync() and I now have a 100% repro with and without hot reload and even without a debugger.
bijington commentedon Jun 20, 2025
@mfeingol excellent work! I can confirm that I can reproduce 100% of the time now.
I've had a Quick Look at our code and there is in fact a
WeakEventManagerinstance for handling the popup close events. I might not be able to look at it today but it looks like we might need a stronger reference.I think the first step will be to reproduce this in a unit test (which I hope should be straightforward given your investigation work) and then debug/fix it
bijington commentedon Jun 20, 2025
@mfeingol I did find time to have a go and I have a PR #2756 that should fix it.
If you get a chance before the PR merges then you could try testing the fix by following the guide at https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages
mfeingol commentedon Jun 20, 2025
@bijington I gave the PR bits a quick spin and they appear to have resolved the problem. Thanks for the legwork here.
bijington commentedon Jun 20, 2025
Thank YOU for all the assistance too! It was easy once you discovered that it was garbage collection related
CyberZeus commentedon Jun 20, 2025
Did you plain to make a release that includes this fix?
Thanks for your work!
bijington commentedon Jun 20, 2025
Yep I think we might have another fix or two to look into and then we can get a release out