Closed GuidoNeele closed 5 months ago
Tracked this issue down to the Loaded event not getting triggered, resulting in the taskCompletionSource not completing, which will keep the task running.
Think this issue is caused by this fix https://github.com/dotnet/maui/commit/21620dc32b85003364a497310231ce48d6831ac7 which is included in 9.0.0-preview.5.24307.10 and 8.0.60
This is not an issue on Android. Didn't test on other platforms.
Issue is fixed if the Unload event is set too.
var taskCompletionSource = new TaskCompletionSource<object?>();
void unloadedHandler(object? sender, EventArgs args) => {};
async void loadedHandler(object? sender, EventArgs args)
{
page.GetCurrentPage().Unloaded -= unloadedHandler;
page.GetCurrentPage().Loaded -= loadedHandler;
try
{
var result = await CreateAndShowPopupAsync(page, popup, token);
taskCompletionSource.TrySetResult(result);
}
catch (Exception ex)
{
taskCompletionSource.TrySetException(ex);
}
}
page.GetCurrentPage().Unloaded += unloadedHandler;
page.GetCurrentPage().Loaded += loadedHandler;
return taskCompletionSource.Task.WaitAsync(token);
Any chance the issue relates to this https://github.com/microsoft/microsoft-ui-xaml/issues/1900
This fix should be available on the nightly feed as version 8.0.61-ci.net8.24319.3
.
Can you test with the latest nightly build? https://github.com/dotnet/maui/wiki/Nightly-Builds
Hi @PureWeen,
Just tried the nightly build and it indeed fixes the issue. Thanks for the swift fix!
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
This is a very strange issue. Since MAUI version 8.0.60 the second popup will fail. Only the second time you want to show a popup will fail. The popup will not show up and if you are using CommunityToolkit.MVVM [RelayCommand] the button (triggering the popup) will be disabled, because the Task will not return. See video of the problem.
https://github.com/CommunityToolkit/Maui/assets/1301586/0cc33ecd-a70e-40fc-a295-5f2255d4e126
Expected Behavior
The popup should always be shown also the second popup.
Steps To Reproduce
Link to public reproduction project repository
https://github.com/CommunityToolkit/Maui
Environment
Anything else?
To prevent the button from disabling while using CommunityToolkit.MVVM is to use [RelayCommand(AllowConcurrentExecutions = true)] instead of [RelayCommand]