Repository navigation
tvOS support, main-thread promise settlement, pin perry-ffi to v0.5.1664 - #2
Merged
Merged
Conversation
…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.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
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.
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_callbackruns on a Swift concurrency thread, andresolve_stringallocated 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 uncaughtError: 0at the firstawait js_storekit_has_subscription(), which killed the app. The callback now copies the JSON and settles throughresolve_with, so the string is allocated on the main thread during the resolution pump.2. tvOS.
crate-iosbuilds the Swift bridge foraarch64-apple-tvosandaarch64-apple-tvos-sim(tvOS 16), andpackage.jsondeclares atvostarget. Before this, an Apple TV build had no StoreKit at all.build-bridges.shand the publish check include the tvOS triples.3. Pin perry-ffi to the
v0.5.1664tag. It used to trackmain, 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 buildfor aarch64-apple-darwin and aarch64-apple-tvos. The archives contain alljs_storekit_*andswift_storekit_*symbols.scripts/build-bridges.shbuilds all 7 triples.has_subscriptionwithout crashing.Summary by CodeRabbit