dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.16k stars 1.74k forks source link

Maui iOS app with defined UISceneConfigurations crashes on force-close with error "System.InvalidOperationException: Window was already destroyed" #24191

Open BenDTU opened 2 months ago

BenDTU commented 2 months ago

Description

A Maui app that is using defined 'UISceneConfigurations' will crash with the error "System.InvalidOperationException: Window was already destroyed" when it is force-closed from the app-switcher. This occurs when running locally and is also reported as a crash in TestFlight.

Steps to Reproduce

  1. Create a new MAUI app
  2. Add a "UIApplicationSceneManifest" section in Info.Plist with a basic 'UIWindowSceneSessionRoleApplication' using '__MAUI_DEFAULT_SCENE_CONFIGURATION__'
  3. Add an matching empty MauiUISceneDelegate
  4. Run the app in the simulator
  5. Double tap the home button and swipe up the app to close, and it will report a crash in the IDE

Link to public reproduction project repository

https://github.com/BenDTU/MauiUISceneConfigurationCrash

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Yes - this crash does not occur on the latest .NET 7 Maui release

Last version that worked well

7.0.101

Affected platforms

iOS

Affected platform versions

Tested on latest iOS

Did you find any workaround?

No - I am unsure what I could do differently, this setup was used from a Maui CarPlay tutorial, but is reproducible without the CarPlay specific code

Relevant log output

No response

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 2 months ago

I can repro this issue at iOS platform on the latest 17.11.0 Preview 7.0 (8.0.80 & 8.0.0-rc.1.9171), but not repro at .NET 7.

PureWeen commented 1 month ago

@BenDTU looking at your sample it looks like you are just setting the MainPage

In order to do multi window you'll need to override createwindow to handle the multiple pages https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/windows?view=net-maui-8.0#create-a-window

BenDTU commented 4 weeks ago

@BenDTU looking at your sample it looks like you are just setting the MainPage

In order to do multi window you'll need to override createwindow to handle the multiple pages https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/windows?view=net-maui-8.0#create-a-window

Overriding CreateWindow as the example there didn't seem to make any difference, the same crash occurs on closing the app.