Skip to content

fix: adopt scene-aware UIWindow lookup for UIScene lifecycle - #18

Merged
OS-ruimoreiramendes merged 1 commit into
mainfrom
fix/RMET-5367/uiscene-migration
Jul 30, 2026
Merged

fix: adopt scene-aware UIWindow lookup for UIScene lifecycle#18
OS-ruimoreiramendes merged 1 commit into
mainfrom
fix/RMET-5367/uiscene-migration

Conversation

@OS-ruimoreiramendes

@OS-ruimoreiramendes OS-ruimoreiramendes commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

Adopts a scene-aware pattern for looking up the current interface orientation, replacing the deprecated UIApplication.shared.windows.first accessor with a new UIApplication.firstKeyWindowForConnectedScenes helper that iterates connectedScenes and picks the key window from the active UIWindowScene.

ref: https://outsystemsrd.atlassian.net/browse/RMET-5367

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

UIApplication.shared.windows has been deprecated since iOS 15.0. In scene-based apps it can return unreliable results, nil or windows from a different scene, which breaks orientation detection during image editing.

Starting with iOS 27, the UIScene lifecycle becomes mandatory (see Apple TN3187). Apps built with the iOS 27 SDK need UIApplicationSceneManifest at the shell level. While that doesn't stop this library from compiling, UIApplication.shared.windows becomes even less reliable in scene-based apps, it may return nil or windows from a different scene, causing silent orientation-detection bugs (editor layout not matching the actual device orientation, especially in iPad Split View / Stage Manager / foldables). Migrating to connectedScenes makes the lookup consistent across single- and multi-scene apps.

The same scene-aware pattern is already in use in OSBarcodeLib-iOS, which has been shipping in Capacitor 8 apps in production.

Tests or Reproductions

Smoke-tested end-to-end via the capacitor-camera example-app and Camera Sample App (ODC) on:
- iPhone 17 (iOS 26.5 simulator) — portrait + landscape + rotation during edit
- **iPhone 15 Pro (iOS 27) — portrait + landscape + rotation during edit
- iPad Pro 13-inch (iOS 26.4 simulator) — portrait + landscape
- iPad Pro 13-inch in Split View (multi-scene) — portrait + landscape + rotation
All orientation transitions adapt the editor layout correctly (bar/buttons repositioning)

In order to test this PR use the Camera Sample App latest build in ODC and/or Camera Example App (capacitor) on branch

Platforms Affected

  • Android
  • iOS
  • Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants