fix(iOS): use per-call ReferencedAssetLoader to prevent concurrent access crash#218
Merged
Merged
Conversation
352df3c to
6572e43
Compare
…cess crash The shared ReferencedAssetLoader on HybridRiveFileFactory caused a data race when multiple RiveFile loads ran concurrently. Concurrent GCD threads calling setFileRef() on the same instance wrote to activeFileRef without synchronization — a non-atomic property write that double-released the previous RiveFile, causing EXC_BAD_ACCESS crashes.
6572e43 to
3adc017
Compare
mfazekas
pushed a commit
that referenced
this pull request
Apr 17, 2026
🤖 I have created a release *beep* *boop* --- ## [0.4.5](v0.4.4...v0.4.5) (2026-04-17) ### Bug Fixes * **iOS:** use per-call ReferencedAssetLoader to prevent concurrent access crash ([#218](#218)) ([d92574d](d92574d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.
Fixes #215
Regression from #202 — the shared
ReferencedAssetLoaderinstance onHybridRiveFileFactorycaused a data race when multipleRiveFileloads ran concurrently (e.g. mounting severalRiveViewcomponents simultaneously).HybridRiveFileFactory.genericFromdispatches file parsing toDispatchQueue.global(qos: .userInitiated). With multiple views mounting at the same time, multiple GCD worker threads calledself.assetLoader.setFileRef(riveFile)on the same shared instance concurrently. Since Swift property assignment (activeFileRef = file) is not atomic — it involves load-old, store-new, release-old as separate steps — two threads could both load the same old value and both release it, causing a double-release (use-after-free) of the previousRiveFile.The fix creates a new
ReferencedAssetLoaderperHybridRiveFileFactory.genericFromcall instead of sharing one on the factory. This matches the Android implementation (HybridRiveFileFactory.ktalready createsval loader = ReferencedAssetLoader()per call). Verified that the retain cycle fix from #202 is not regressed (memgraph shows no leakedRiveFileafter navigating away from referenced asset screens).Reproducer
Rapidly mount/unmount multiple
RiveViewcomponents (8+ views toggling at 10-50ms intervals, 1000+ cycles). Requires Expo SDK 55 / RN 0.83.4 — does not reproduce on Expo SDK 54 / RN 0.81.Reproducer component (Issue215.tsx)