Skip to content

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

Open
mfazekas wants to merge 1 commit intomainfrom
fix/ios-preloaded-image-dispatch-crash
Open

fix(iOS): dispatch completion to main thread in handlePreloadedImage#222
mfazekas wants to merge 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
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

1 participant