Skip to content

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

Open

Description

@MartinZikmund

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.

Activity

  1. added
    kind/bug
    platform/ios 🍎
    area/skia ✏️
    on Sep 29, 2026
  2. MartinZikmund commented on Sep 29, 2026

    @MartinZikmund
    MemberAuthor

    Proposed fix: #24814

  3. added
    7.1
    on Oct 14, 2026
  4. removed
    7.1
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/skia ✏️kind/bugplatform/ios 🍎

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions