Skip to content

Create iOS windows with scene lifecycle - #99

Merged
Try merged 6 commits into
Try:masterfrom
tryk016:codex/pr-tempest-ios-window-scene-lifecycle-draft
Sep 10, 2026
Merged

Try merged 6 commits into
Try:masterfrom
tryk016:codex/pr-tempest-ios-window-scene-lifecycle-draft

Conversation

@tryk016

@tryk016 tryk016 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This moves native iOS window creation out of didFinishLaunchingWithOptions and into Tempest createWindow. It uses the UIWindowScene lifecycle, creates the window for the connected scene, and pauses rendering while the scene is inactive.

The display-link callback only marks a frame pending and queues the engine resume after the UIKit callback has returned. Queued callbacks are discarded after a lifecycle transition.

The iOS deployment target is now 15. iOS hosts must provide UIApplicationSceneManifest. Tempest continues to expose one native iOS window.

appleMain remains non-inlined so its stack frame is created after Tempest switches to appleStack.

Validated with macOS tests, iPhoneOS and iPhone Simulator builds, strict compilation and static analysis, simulator background/resume, and the scene-disconnect teardown probe.

@tryk016
tryk016 force-pushed the codex/pr-tempest-ios-window-scene-lifecycle-draft branch from 8227194 to 4dcff15 Compare September 8, 2026 20:49
@tryk016
tryk016 marked this pull request as ready for review September 8, 2026 21:00
@Try

Try commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Hi @tryk016 !

From what I know, scene-life cycle makes sense only if application is going to support multiple window, at cost of overengineering.
In this PR - window is still single and global.
sceneDidDisconnect is quite an issue - now window can be sporadically destroyed, causing System::Window* to become dangling reference.

As alternative, maybe raise isExit flag at sceneDidDisconnect and allow game to tear-down. Then rest is fine, and we can also support multiple windows.

@tryk016

tryk016 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

You're right about sceneDidDisconnect:. I overcomplicated the surrounding handling while the backend still has a single window. I've simplified the PR and removed the reconnection and second-scene handling. sceneDidDisconnect: now sets the exit flag and lets the window tear down normally.

@Try Try left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Look good now already.
As cleanup: I think it's fine to bump build target to 13 (or event 15) - so we wont need support iOS before UIWindowScene.

@tryk016

tryk016 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Bumping the iOS deployment target to 15 makes sense. It will let me remove the legacy app delegate path and should simplify the next iOS changes as well. I'll update the PR.

Comment thread Engine/system/api/iosapi.mm Outdated

static void configureWindowForScene(TempestWindow* window, UIWindowScene* scene)
API_AVAILABLE(ios(13.0)) {
#if defined(__IPHONE_26_0) && \

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why do you need compile-time and runtime checks side-by-side here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The compile-time check keeps Tempest buildable with SDKs older than 26, where UIWindowSceneGeometry.coordinateSpace isn't declared. The runtime check is needed because we target iOS 15, so a build made with the current SDK can still run on iOS 15–25.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

sure, I can read that from the code :)

Question is: is pre 26 sdk needed for anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don’t need it for the port. I kept it for older Xcode versions, but even the 2018 Intel Mac mini can run Xcode 26.0. Do you see a reason to keep supporting older SDKs, or would SDK 26 be a reasonable minimum for Tempest?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, it's totally fine, since it's matter of download for developer.
If something - we can always bring back guards.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed the compile-time guard.

@Try
Try merged commit 1b777ec into Try:master Sep 10, 2026
4 checks passed
@Try

Try commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

@tryk016
tryk016 deleted the codex/pr-tempest-ios-window-scene-lifecycle-draft branch September 11, 2026 10:01
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