-
Notifications
You must be signed in to change notification settings - Fork 3
feat(cdn): adding in cdn caching #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This is great @bassrock! We'll get this reviewed Edit: and thanks for the contribution + early feedback |
ios/ReferencedAssetLoader.swift
Outdated
| } | ||
| } | ||
|
|
||
| func dispose() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this dispose is called from?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm actually looks like it never is. Guess its a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW we've ended up merging a slightly different fix for the iOS crash. #45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfazekas I was also seeing a similar issue on Android
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the disposal on android and ios, and rebased on main
f68cf0c to
e52a135
Compare
b628586 to
42c36a9
Compare
42c36a9 to
c513f3d
Compare
|
@mfazekas I have made updates since the view stuff was fixed elsewhere. This now fixes just referenced assets and adds in a Cache layer |
756b341 to
3b94ed6
Compare
example/android/.kotlin/sessions/kotlin-compiler-12952147549113407283.salive
Outdated
Show resolved
Hide resolved
…to db/feat/cdn-cache
|
@bassrock FYI this approach is challenging to implement on the new experimental iOS runtime. The experimental API uses Worker global assets instead of the // Experimental: register assets on Worker (can be before OR after File creation)
let worker = await Worker()
let image = worker.decodeImage(from: imageData)
worker.addGlobalImageAsset(image, name: "referenced-image-2929282") // must know
exact name
let file = try await File(source: .data(data), worker: worker)
|
|
@mfazekas when using the hosted RiveCDN does the new Runtime though have a way to cache the loaded assets (and the app doesnt know about it)? For example we use the same Rive File across our app that uses assets from the RiveCDN, ideally we don't want the same image loading from the network on each different view of the Rive file. |
Description
This PR adds URL-based asset caching to the
ReferencedAssetLoaderon both Android and iOS platforms. The implementation introduces a dedicatedURLAssetCachemodule that caches downloaded HTTP/HTTPS assets to disk, improving performance by avoiding redundant network requests for the same assets.Changes Made
URL Asset Caching
URLAssetCacheModule: Created a dedicated caching system for URL-based assets on both platformsAndroid (
URLAssetCache.kt):cacheDir/rive_url_assets/getCachedData(),saveToCache(), andclearCache()methodsiOS (
URLAssetCache.swift):cachesDirectory/rive_url_assets/ReferencedAssetLoader Updates
Cache Integration: Both Android and iOS loaders now check the cache before downloading HTTP/HTTPS assets
Asset Cache Management in
createCustomLoader:uniqueNameandnamekeys)referencedAssetslater in the file lifecycle. Since assets are cached immediately, new referenced assets can be provided and will properly associate with existing file assets throughout the file's lifecycle.Additional Changes
Unitinstead of empty mapAdditional Information
Technical Details
Cache Key Generation:
Cache Storage:
Cache Strategy:
Asset Cache Management: The
createCustomLoaderfunction now immediately caches all assets (both byuniqueFilename/uniqueNameandname) when they are first encountered, regardless of whether they've been loaded yet. This ensures:Breaking Changes
None - this is a backward-compatible enhancement. Existing functionality remains unchanged, with caching added as an optimization layer.