RFR: 8377350: [iOS] Add support for UIWindowScene

Jose Pereda jpereda at openjdk.org
Thu Feb 12 14:22:22 UTC 2026


On Thu, 12 Feb 2026 13:16:26 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:

>> This PR adds support for iOS native window scene, which was added some time ago starting iOS 13 (in 2019).
>> 
>> Current iOS development requires iOS SDK 26, and minimum deployment target is set to iOS 15 (meaning that apps will run on all devices with iOS 15 or greater).
>> 
>> It is safe then to not include the safe-guard `if (@available(iOS 13.0, *)) {...}`, which will make the code more complex.
>> 
>> Adding the native UIScene and UIWindowScene APIs follows the Apple standards, but as a fallback, the deprecated API is still kept there (`keyWindow` was deprecated starting iOS 13, and `initWithFrame:` was deprecated starting iOS 26). This is for a follow-up issue.
>> 
>> Note: This patch doesn't really add support for multiple windows, as this would require more complex changes.
>
> modules/javafx.graphics/src/main/native-glass/ios/GlassWindow.m line 840:
> 
>> 838:             UIWindowScene *windowScene = (UIWindowScene *)[[UIApplication sharedApplication] connectedScenes].allObjects.firstObject;
>> 839:             if (windowScene) {
>> 840:                 UIWindow *window = windowScene.windows.firstObject;
> 
> Is there a chance `windowScene.windows` can be `null` here?

Good question! 
It can't be null, as long as the iOS lifecycle does create by default a Scene and a Window. 

Also, checking UIWindowScene header:


// The array of all windows associated with this UIWindowScene
@property (nonatomic, readonly) NSArray<UIWindow *> *windows;

@property (nullable, nonatomic, strong) UIWindow *window;


the`windows` array is not nullable, whereas the `window` can be null.

Also, the same applies to `connectedScenes`:

@property(nonatomic, readonly) NSSet<UIScene *> *connectedScenes


While the set won't be null, it _might_ be empty (meaning there are no active scenes in the application, due to not having any UI scenes connected, that is no screens/displays even if there is an app running...), and `windowScene` might be null.

The PR already guards against this case with `if (windowScene) {... }`, but I didn't add the `else` case. Will do now.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2072#discussion_r2799157277


More information about the openjfx-dev mailing list