Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ios/HybridRiveFileFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ final class HybridRiveFileFactory: HybridRiveFileFactorySpec, @unchecked Sendabl

let referencedAssetCache = SendableRef(ReferencedAssetCache())
let factoryCache: SendableRef<RiveFactory?> = .init(nil)
let fileRef: SendableRef<RiveFile?> = .init(nil)
let customLoader = self.assetLoader.createCustomLoader(
referencedAssets: referencedAssets, cache: referencedAssetCache,
factory: factoryCache)
factory: factoryCache,
fileRef: fileRef
)

let riveFile =
if let customLoader = customLoader {
try fileWithCustomAssetLoader(prepared, customLoader)
} else {
try file(prepared)
}
fileRef.value = riveFile

let result = (
file: riveFile, cache: referencedAssetCache.value, factory: factoryCache.value,
Expand Down
7 changes: 5 additions & 2 deletions ios/ReferencedAssetLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ final class ReferencedAssetLoader {

func createCustomLoader(
referencedAssets: ReferencedAssetsType?, cache: SendableRef<ReferencedAssetCache>,
factory factoryOut: SendableRef<RiveFactory?>
factory factoryOut: SendableRef<RiveFactory?>,
fileRef: SendableRef<RiveFile?>
)
-> LoadAsset?
{
Expand All @@ -244,7 +245,9 @@ final class ReferencedAssetLoader {
cache.value[asset.uniqueName()] = asset
factoryOut.value = factory

self.loadAssetInternal(source: assetData, asset: asset, factory: factory, completion: {})
self.loadAssetInternal(source: assetData, asset: asset, factory: factory, completion: {
withExtendedLifetime(fileRef) {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool!

})

return true
}
Expand Down
Loading