Skip to content

[iOS] Block external roles from activating UIScene - #21844

Merged
MrJul merged 1 commit into
mainfrom
dev/timill/uiwindow-scene-delegate
Jul 24, 2026
Merged

[iOS] Block external roles from activating UIScene#21844
MrJul merged 1 commit into
mainfrom
dev/timill/uiwindow-scene-delegate

Conversation

@drasticactions

Copy link
Copy Markdown
Contributor

Fixes #21832

This PR updates the scene connection logic in AvaloniaSceneDelegate to better protect against non-application scenes. When you screen mirror, the UIScene would be invoked with roles that would end up stealing views. Long-term, we need to refactor how scene delegates work with UIKit, but for now, to keep everything working and consistent, we only support the Application instance and ignore the others. That will allow stuff like AirPlay to work.

Copilot stuff below:

Scene connection safety:

  • Added a check to ensure that only scenes with the Application role are handled, preventing unintended handling of system-created scenes (e.g., for external displays or CarPlay) in the WillConnect method of AvaloniaSceneDelegate (Avalonia.iOS/AvaloniaSceneDelegate.cs).

@MrJul MrJul added bug os-ios backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 24, 2026

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrJul
MrJul enabled auto-merge July 24, 2026 10:35
@MrJul
MrJul added this pull request to the merge queue Jul 24, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067683-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@freddiesmartbox

freddiesmartbox commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Thanks for the insanely fast turn-around on this!

I'm trying to test at the moment, but having trouble with my dev machine: shall report back as soon as possible...

Merged via the queue into main with commit e5cd8c3 Jul 24, 2026
10 checks passed
@MrJul
MrJul deleted the dev/timill/uiwindow-scene-delegate branch July 24, 2026 11:46
@freddiesmartbox

Copy link
Copy Markdown
Contributor

Can confirm the issue we were seeing is fixed with 12.2.999-cibuild0067683-alpha

Thanks again for addressing this so quickly

@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Screen Mirroring on iOS does not work in Avalonia 12

4 participants