- 
                Notifications
    You must be signed in to change notification settings 
- Fork 462
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
This appears to be a conflict between the latest Popup functionality and AppShell/TitleBar. While the two operate correctly, they are causing a conflict that causes the application to crash when exiting. No stack dump is available and can be reproduced on a hello world app. Specifically, the unhandled exception occurs:
Exception: Value does not fall within the expected range.
Message: Invalid window; it belongs to other thread.
Expected Behavior
Exiting the application should not have an error.
Steps To Reproduce
- Create a MAUI project on Windows, DotNet9. Target the build/debug for localhost.
- I believe this is optional, but in NUGET, perform all updates (should only be a couple)
- Add Community Toolkit needed for Popups
- Create a new view, change the parent to Popup.
- I changed the popup constructor to accept an action, call the action on button click
- In MainPage.xaml.cs, add this code to bring up the popup:
`protected override async void OnAppearing()
{
if (!firstLoad) return;
firstLoad = false;
CancellationToken token = new();
var popup = new PageTest(async () =>
{
await this.ClosePopupAsync(token);
});
await this.ShowPopupAsync(
//await Shell.Current.ShowPopupAsync(
popup,
new PopupOptions(),
token);
}`
- Run the app, close the popup, then close the app. It should close correctly.
- Change this method in the App.xaml.cs:
protected override Window CreateWindow(IActivationState? activationState) { return new Window(new AppShell()) { // BUG - this option causes popups to crash TitleBar = new TitleBar() { Title = "title", Subtitle = "subject" } }; }
- Repeat running the app. Close the popup, close the app.
- An unhandled exception should occur.
- Alternatively, comment out the popup also fixes the crash.
Link to public reproduction project repository
https://github.com/brendanrempel/popupcrash/tree/main/MauiPopup
Environment
- .NET MAUI CommunityToolkit: 12.2.0
- OS: Windows 24H2 26120.5770
- .NET MAUI: DotNet 9
- Version 17.14.14Anything else?
Duplicate of 2877 which was closed without resolving.