Skip to content

fix(iOS): dispatch completion to main thread in handlePreloadedImage#222

Merged
mfazekas merged 1 commit intomainfrom
fix/ios-preloaded-image-dispatch-crash
Apr 23, 2026
Merged

fix(iOS): dispatch completion to main thread in handlePreloadedImage#222
mfazekas merged 1 commit intomainfrom
fix/ios-preloaded-image-dispatch-crash

Conversation

@mfazekas
Copy link
Copy Markdown
Collaborator

@mfazekas mfazekas commented Apr 17, 2026

Fixes #221

handlePreloadedImage was calling completion() synchronously on the Rive C++ runtime's background import queue, but completion triggers releaseFile() which asserts main thread via dispatchPrecondition. Every other asset path in ReferencedAssetLoader already dispatches to main before calling completion() — this was the only one missing it.

Crash stack (reproduced locally)

_assertionFailure
ReferencedAssetLoader.handlePreloadedImage(_:asset:completion:)
ReferencedAssetLoader.loadAssetInternal(source:asset:factory:completion:)
closure #1 in ReferencedAssetLoader.createCustomLoader(...)
rive::File::import(...)  ← background queue
HybridRiveFileFactory.genericFrom(...)  ← DispatchQueue.global(.userInitiated)

Reproduced using the Out-of-Band Assets (Suspense) exerciser which calls RiveImages.loadFromURLAsync and passes the preloaded RiveImage via referencedAssets.

@mfazekas mfazekas force-pushed the fix/ios-preloaded-image-dispatch-crash branch from 4506a15 to aba5a82 Compare April 20, 2026 20:28
handlePreloadedImage was calling completion() synchronously on the Rive
C++ runtime's background import queue, but completion triggers
releaseFile() which asserts main thread via dispatchPrecondition.
@mfazekas mfazekas force-pushed the fix/ios-preloaded-image-dispatch-crash branch from aba5a82 to 6d459c9 Compare April 21, 2026 06:45
@mfazekas mfazekas requested a review from HayesGordon April 21, 2026 06:51
Copy link
Copy Markdown
Contributor

@HayesGordon HayesGordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mfazekas mfazekas merged commit 5c043d4 into main Apr 23, 2026
9 checks passed
@mfazekas mfazekas deleted the fix/ios-preloaded-image-dispatch-crash branch April 23, 2026 13:47
mfazekas pushed a commit that referenced this pull request Apr 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.4.6](v0.4.5...v0.4.6)
(2026-04-23)


### Bug Fixes

* **iOS:** dispatch completion to main thread in handlePreloadedImage
([#222](#222))
([5c043d4](5c043d4))
* prevent crash when React Fabric diffs props on disposed HybridObject
([#227](#227))
([8286bcf](8286bcf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

iOS crash: dispatchPrecondition failure in ReferencedAssetLoader.releaseFile() when using preloaded images via RiveImages.loadFromURLAsync

2 participants