Skip to content

tvOS support, main-thread promise settlement, pin perry-ffi to v0.5.1664 - #2

Merged
proggeramlug merged 2 commits into
mainfrom
tvos
Nov 8, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
tvos

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes found while wiring StoreKit 2 into a Perry + Bloom game (Chesslings) for iPhone, iPad, Mac and Apple TV.

1. Settle promises on Perry's main thread. storekit_callback runs on a Swift concurrency thread, and resolve_string allocated the JS string there, in that thread's arena. perry-ffi documents that as undefined behaviour (#1824 in PerryTS/perry). In a Bloom app on macOS it showed up as an uncaught Error: 0 at the first await js_storekit_has_subscription(), which killed the app. The callback now copies the JSON and settles through resolve_with, so the string is allocated on the main thread during the resolution pump.

2. tvOS. crate-ios builds the Swift bridge for aarch64-apple-tvos and aarch64-apple-tvos-sim (tvOS 16), and package.json declares a tvos target. Before this, an Apple TV build had no StoreKit at all. build-bridges.sh and the publish check include the tvOS triples.

3. Pin perry-ffi to the v0.5.1664 tag. It used to track main, which is now 0.6.0 and needs nightly (#![feature(linkage)]), so any stable build failed with E0554. The pin keeps the ABI in step with a released compiler.

Version bumped to 0.1.4.

Tested:

  • cargo build for aarch64-apple-darwin and aarch64-apple-tvos. The archives contain all js_storekit_* and swift_storekit_* symbols.
  • scripts/build-bridges.sh builds all 7 triples.
  • A Perry 0.5.1664 macOS app (Bloom, ios-game-loop runtime) signed with a development profile loads the product's price from the App Store sandbox and answers has_subscription without crashing.
  • Not yet tested: the purchase sheet itself, and on-device iOS/tvOS runs.

Summary by CodeRabbit

  • New Features
    • Added tvOS support for StoreKit, including tvOS 16 and later.
    • The package now supports iOS, tvOS, and macOS.

…ease

- crate-ios builds the Swift bridge for aarch64-apple-tvos and the tvOS
  simulator (appletvos / appletvsimulator SDKs, tvOS 16), and package.json
  declares a tvos target, so perry links the real bridge on Apple TV
  instead of failing to find one.
- scripts/build-bridges.sh and the publish check cover the tvOS triples.
- perry-ffi came from PerryTS/perry main, which is now 0.6.0 and needs
  nightly (#![feature(linkage)]); building with stable Rust failed with
  E0554. Pin it to the v0.5.1664 tag (the released compiler), so the ABI
  matches the Perry that links the app.
- Bump to 0.1.4.
storekit_callback runs on a Swift concurrency thread. resolve_string
allocated the JS string right there, in that thread's arena, which
perry-ffi documents as undefined behaviour (perry#1824). In a Bloom app on
macOS it surfaced as an uncaught 'Error: 0' at the first await of
js_storekit_has_subscription(). Copy the JSON on the Swift thread and let
resolve_with allocate the string on the main thread during the resolution
pump.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The package adds tvOS support for the native Swift StoreKit bridge, including device and simulator targets. It also pins perry-ffi to v0.5.1664 and changes callback promise resolution to allocate the JavaScript string during resolution.

Changes: tvOS bridge support

Layer / File(s) Summary
FFI version and callback resolution
crate-ios/Cargo.toml, crate-stub/Cargo.toml, crate-ios/src/apple.rs
Both crates pin perry-ffi to v0.5.1664. The StoreKit callback now allocates the JavaScript string inside resolve_with.
tvOS bridge targets and crate routing
crate-ios/build.rs, crate-ios/src/lib.rs, scripts/build-bridges.sh
The crate routes tvOS to the Apple bridge. Build configuration adds tvOS device and simulator targets, their SDK mappings, and Swift library path handling.
Package targets and archive verification
package.json, README.md, .github/workflows/publish.yml
Package metadata and the README list tvOS support. The publish workflow checks that tvOS bridge archives are nonempty.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: Moderate · up to a9256

StoreKit calls from Perry workers may hang or settle on the wrong agent. Fix promise routing before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@proggeramlug
proggeramlug merged commit 8dbd8c2 into main Nov 8, 2026
4 of 5 checks passed
@proggeramlug
proggeramlug deleted the tvos branch November 8, 2026 08:34
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.

1 participant