feat(visionos): UIKit+Metal game-loop link path for visionOS#5087
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughVisionOS game-loop support is added by extending the existing ChangesVisionOS game-loop feature support
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry/src/commands/compile/link/mod.rs`:
- Line 333: The visionOS UI path is wrongly dropping the runtime for apps built
with the ios-game-loop feature; modify the logic that sets skip_runtime so that
when compiled_features contains "ios-game-loop" and ctx.needs_ui && is_visionos
you do NOT set skip_runtime (keep runtime_lib linked instead of only linking
libperry_ui_visionos.a), and also ensure the fallback rebuild invocation
includes the --features ios-game-loop flag so the renamed
ios_game_loop/__perry_user_main export is produced; update references to
compiled_features, skip_runtime, runtime_lib, libperry_ui_visionos.a and the
fallback rebuild invocation accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d2ae5234-7cd3-4852-b2d8-ae576812051e
📒 Files selected for processing (3)
crates/perry-runtime/src/lib.rscrates/perry/src/commands/compile/link/mod.rscrates/perry/src/commands/compile/link/platform_cmd.rs
| // entry object file so the perry runtime's main() (from ios_game_loop.rs) | ||
| // becomes the process entry point. It spawns _perry_user_main on a game thread. | ||
| if (is_ios || is_tvos) && compiled_features.iter().any(|f| f == "ios-game-loop") { | ||
| if (is_ios || is_tvos || is_visionos) && compiled_features.iter().any(|f| f == "ios-game-loop") { |
There was a problem hiding this comment.
Don’t drop runtime_lib for visionOS ios-game-loop UI apps.
Line 333 turns the game-loop entry rename on for visionOS, but the same function later still sets skip_runtime for every is_visionos && ctx.needs_ui build and then links only libperry_ui_visionos.a. That archive bundles its own perry-runtime, and the fallback rebuild command at Lines 1259-1260 does not pass --features ios-game-loop, so it will not export the new ios_game_loop main() / __perry_user_main handoff. A visionos + perry/ui + ios-game-loop app will therefore lose the process entry shim even though _main was renamed.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/perry/src/commands/compile/link/mod.rs` at line 333, The visionOS UI
path is wrongly dropping the runtime for apps built with the ios-game-loop
feature; modify the logic that sets skip_runtime so that when compiled_features
contains "ios-game-loop" and ctx.needs_ui && is_visionos you do NOT set
skip_runtime (keep runtime_lib linked instead of only linking
libperry_ui_visionos.a), and also ensure the fallback rebuild invocation
includes the --features ios-game-loop flag so the renamed
ios_game_loop/__perry_user_main export is produced; update references to
compiled_features, skip_runtime, runtime_lib, libperry_ui_visionos.a and the
fallback rebuild invocation accordingly.
visionOS was wired only as a SwiftUI app (swiftc + PerryVisionApp.swift, `_main -> _perry_main_init`), which can't host a Metal/wgpu game. Mirror the watchOS dual-model approach so `--features ios-game-loop` produces a UIKit + CAMetalLayer game-loop app on visionOS: - perry-runtime: compile the `ios_game_loop` module (the C `main()` that spawns the user's TS on a game thread and calls UIApplicationMain) for `target_os = "visionos"` too, not just ios/tvos. - link/mod.rs: include visionOS in the `_main -> __perry_user_main` entry-rename so the runtime's main() becomes the process entry. - platform_cmd.rs: add an `ios-game-loop` sub-branch to the visionOS linker selection that links with clang (iOS-style: Swift-stdlib search paths + libc++) instead of swiftc — no PerryVisionApp.swift required. The default (non-game-loop) SwiftUI path is unchanged. Verified end-to-end: builds + runs a Bloom Engine game on the visionOS simulator and device, and the device IPA validates + uploads to App Store Connect (TestFlight).
22386e0 to
7afaa8e
Compare
What
visionOS was wired only as a SwiftUI app (linked with
swiftc, requiringPerryVisionApp.swift, renaming_main → _perry_main_init). That model can't host a Metal/wgpu game — there's no SwiftUI scene tree, the native lib owns aCAMetalLayerand the runtime providesmain().This adds the UIKit + Metal game-loop model for visionOS, mirroring the existing watchOS dual-model approach: with
--features ios-game-loop, visionOS now builds exactly like iOS/tvOS (UIKitUIApplicationMain+CAMetalLayer+ wgpu surface on scene-connect).Changes
perry-runtime/src/lib.rs— compile theios_game_loopmodule (the Cmain()that spawns the user's TS on a game thread and callsUIApplicationMain) fortarget_os = "visionos"as well, not justios/tvos. Without this the runtime has nomain()for visionOS game-loop apps.link/mod.rs— include visionOS in the_main → __perry_user_mainentry-rename so the runtime'smain()becomes the process entry point (shared with iOS/tvOS).link/platform_cmd.rs— add anios-game-loopsub-branch to the visionOS linker selection that links with clang (iOS-style: Swift-stdlib search paths +-lc++/-lc++abifor the engine's C++ deps) instead ofswiftc. NoPerryVisionApp.swiftrequired. The default (non-game-loop) SwiftUI path is unchanged.Testing
Verified end-to-end with a Bloom Engine 2D game:
--target visionos-simulator) and device (--target visionos)..ipavalidates and uploads to App Store Connect (TestFlight) with no errors.aarch64-apple-visionos{,-sim}are tier-2 Rust targets (no-Zbuild-std).Companion
Pairs with the Bloom Engine native-layer PR (the
native/visionoscrate) — this is the perry-toolchain half.Summary by CodeRabbit