#24813·uno

[iOS] Scene disconnect closes the XAML Window, but iOS also disconnects backgrounded scenes that can reconnect

Author: MartinZikmundCreated Sep 29, 2026Updated Sep 29, 2026
Labelskind/bugplatform/ios 🍎area/skia ✏️

Current behavior

Found by code review; not reproduced on a device yet.

UnoUISceneDelegate.DidDisconnect → NativeWindowWrapper.OnSceneDisconnected() raises Closing/Closed and closes the XAML Window.

UIKit also disconnects scenes that are merely backgrounded, to reclaim memory, and those may reconnect later (sceneDidDisconnect(_:): "The scene may reconnect later, as its session was not necessarily discarded"). The signal that the user actually closed the window is application(_:didDiscardSceneSessions:), which UnoUIApplicationDelegate does not handle.

Resulting sequence on iPad:

  1. The app has a secondary window, and the user backgrounds it.
  2. iOS reclaims the scene → DidDisconnect → Uno closes the XAML Window (and Window.Closed fires even though the user never closed it).
  3. The user taps the window in the app switcher → the same session reconnects. connectionOptions carries no Uno GUID, so the window is either destroyed (No window is awaiting a scene) or matched through the "oldest pending window" fallback and takes an unrelated pending window.

Expected behavior

A disconnect only removes the window's native surface. The XAML Window stays alive and is re-bound when the same session (UISceneSession.PersistentIdentifier) reconnects. Window.Closed fires when the session is discarded, or when the app calls Close().

How to reproduce it (as minimally and precisely as possible)

  1. SamplesApp (scene manifest enabled) on the iPad simulator. Open a secondary window.
  2. Background the app, then force scene disconnection. Either use Xcode → Debug → Simulate Memory Warning while backgrounded, or open enough other apps. The disconnect can be confirmed with a log in OnSceneDisconnected.
  3. Return to the secondary window from the app switcher.
  4. Suspected actual: the window's Closed was raised, and the reconnected session is discarded or shows the wrong content.

Workaround ️

None known.

Renderer

  • Skia
  • Native

Affected platforms ️

iOS

Uno.Sdk version (and other relevant versions)

master (after #19082)

IDE version ‍

N/A

Anything else we need to know?

The proposed redesign that fixes this is in the linked enhancement issue. Related: #19082, #8341.