Fix tvOS simulator support (Jolt sim archive, libc++, CAMetalLayer present, wgpu limits, file I/O)#58
Merged
Merged
Conversation
find_prebuilt_dir keyed the jolt-prebuilt lookup only on
{target_os}-{target_arch}, so every Apple *-sim target (tvos/ios/watchos)
resolved to the device archive (e.g. tvos-arm64) and linked a device-built
Jolt object into a simulator build. ld then rejects it:
building for 'tvOS-simulator', but linking in object file built for 'tvOS'
jolt-prebuilt already ships the correct <os>-<arch>-sim archives; select
them by appending -sim when CARGO_CFG_TARGET_ABI == "sim". Device builds
are unaffected. Fixes the link step for the tvOS/iOS/watchOS simulators.
The tvos target in perry.nativeLibrary.targets declared frameworks but no libs, unlike macos which lists ["c++"]. The Jolt C++ objects pull in libc++ symbols (___cxa_guard_acquire/release, etc.), so a tvOS link failed with unresolved symbols. Add "libs": ["c++"] to match macos.
… I/O
Three runtime bugs that prevented the tvOS native layer from running a game,
plus debug-scaffold cleanup:
- CAMetalLayer.presentsWithTransaction was YES in both scene_will_connect and
deferred_init. wgpu presents its drawable asynchronously via
-presentDrawable:, which is incompatible: CoreAnimation waits for a
synchronous CATransaction commit that never comes, so the layer never
displays rendered frames (screen stays black behind UIKit subviews). Set NO.
- request_device asked for wgpu::Limits::default()
(max_inter_stage_shader_variables = 16), but the tvOS/iOS simulators' Metal
only allows 15, so device creation panicked with LimitsExceeded. Clamp that
limit to adapter.limits(); real hardware meets/exceeds default() so it is
unchanged.
- bloom_read_file returned std::ptr::null() on a missing/unreadable file and
hand-rolled the obsolete Perry-0.4 8-byte string header. Perry 0.5.x reads
.length by dereferencing (ptr - 8), so a null string segfaults the caller,
and the 8-byte header (data@8 vs the 0.5.x 20-byte StringHeader's data@20)
returned garbage even for existing files. Route both branches through
alloc_perry_string; return an empty string, never null.
- Remove two debug UILabels ("BLOOM JUMP TVOS" / "...DEBUG") that were
drawn over the game to verify window visibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A game compiled for
--target tvos-simulatorfailed to run on the tvOS simulator at five separate points. This PR fixes all of them; the result is the full game (title screen and gameplay — tiles, sprites, enemies, HUD) rendering correctly on the Apple TV simulator.Each failure was found by fixing the prior one and re-running, so they're layered:
building for 'tvOS-simulator', but linking in object file built for 'tvOS'find_prebuilt_dirkeyed jolt-prebuilt only on{os}-{arch}, so every Apple*-simtarget linked the device Jolt archive-simwhenCARGO_CFG_TARGET_ABI == "sim"to select the shipped<os>-<arch>-simarchive___cxa_guard_acquire/releaseframeworksbut nolibs; Jolt's C++ needs libc++"libs": ["c++"](matchesmacos)request_device→LimitsExceeded { max_inter_stage_shader_variables: requested 16, allowed 15 }wgpu::Limits::default(); the simulator's Metal caps it at 15adapter.limits()CAMetalLayer.presentsWithTransaction = YES— incompatible with wgpu's async-presentDrawable:; CoreAnimation waits for a CATransaction commit that never happensNO(bothscene_will_connectanddeferred_init)SIGSEGVat0xfffffffffffffff8entering a levelbloom_read_filereturnednullon a missing file; Perry's inline.lengthdereferences(ptr-8). Also used the obsolete 8-byte string header (data@8 vs 0.5.x's 20-byteStringHeaderdata@20), corrupting even valid readsalloc_perry_string; return an empty string, never nullAlso removes two leftover debug
UILabels that were drawn over the game to verify window visibility.Scope note
Fix #1 (
build.rs) also repairs the iOS and watchOS simulator link paths, which had the same device-archive bug.Validation
bloom-tvosforaarch64-apple-tvos-sim— compiles clean.Apple TV 4K (3rd gen)tvOS 26 simulator: title screen, then a playable level (player, grass/dirt tiles, coins, walker enemies, spikes, gem, HUD hearts/lives).