imsamgarg / firebase_cached_image Goto Github PK
View Code? Open in Web Editor NEWCache Manager and Cached ImageProvider for Firebase Cloud Storage Objects.
License: MIT License
Cache Manager and Cached ImageProvider for Firebase Cloud Storage Objects.
License: MIT License
Can't track image loading status because loadingBuilder doesn't return ImageChunkEvent
Hello how i can cache svg using firebase ?
Would love a feature that includes a parameter in CacheOptions
along the lines of timeToRefresh
where I can set how many seconds an image should be in a cache before it's refreshed.
@imsamgarg
have you evaluated the potential of using ISAR as a backend for storing the cached Images?
In our app we encountered an issue where a video stored on Firebase Storage would not play if it wasn't already cached locally. Instead of fetching and playing the video from the server, the app would display a black screen and log a "file not found" exception.
Here are the error logs for reference:
E/ExoPlayerImplInternal(12046): at android.os.Looper.loopOnce(Looper.java:201)
E/ExoPlayerImplInternal(12046): at android.os.Looper.loop(Looper.java:288)
E/ExoPlayerImplInternal(12046): at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(12046): Caused by: com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException: java.io.FileNotFoundException: /data/user/0/jp.smartbooks.kodomamo.parentapp/cache/flutter_cached_image/81361b96-0d8b-5910-a5be-251b14dd9261.mp4: open failed: ENOENT (No such file or directory)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.FileDataSource.openLocalFile(FileDataSource.java:203)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.FileDataSource.open(FileDataSource.java:114)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:263)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal(12046): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/ExoPlayerImplInternal(12046): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/ExoPlayerImplInternal(12046): at java.lang.Thread.run(Thread.java:1012)
E/ExoPlayerImplInternal(12046): Caused by: java.io.FileNotFoundException: /data/user/0/jp.smartbooks.kodomamo.parentapp/cache/flutter_cached_image/81361b96-0d8b-5910-a5be-251b14dd9261.mp4: open failed: ENOENT (No such file or directory)
E/ExoPlayerImplInternal(12046): at libcore.io.IoBridge.open(IoBridge.java:574)
E/ExoPlayerImplInternal(12046): at java.io.RandomAccessFile.(RandomAccessFile.java:289)
E/ExoPlayerImplInternal(12046): at java.io.RandomAccessFile.(RandomAccessFile.java:152)
E/ExoPlayerImplInternal(12046): at com.google.android.exoplayer2.upstream.FileDataSource.openLocalFile(FileDataSource.java:184)
E/ExoPlayerImplInternal(12046): ... 8 more
E/ExoPlayerImplInternal(12046): Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
E/ExoPlayerImplInternal(12046): at libcore.io.Linux.open(Native Method)
E/ExoPlayerImplInternal(12046): at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
E/ExoPlayerImplInternal(12046): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
E/ExoPlayerImplInternal(12046): at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
E/ExoPlayerImplInternal(12046): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7756)
E/ExoPlayerImplInternal(12046): at libcore.io.IoBridge.open(IoBridge.java:560)
E/ExoPlayerImplInternal(12046): ... 11 more
To address this problem, we implemented a manual check to determine whether the video was already cached. If it was not found in the cache, we would explicitly set the source to Source.server
. Conversely, if the video was cached, we used Source.cacheServer
. This solution successfully resolved the playback issue.
Just implemented this to my project and getting great results so far. As a test I changed my url to be wrong and this causes an error of course. Is there a way to handle such an error with this package? If not what would be the best way to do so manually?
Thanks in advance
Instead of waiting for the cache to resolve and complete the download, we can use the downloadURL to show an image in the meantime the cache is populated. This will download the asset twice, but the second time we can get it from the cache.
Because every version of firebase_cached_image depends on firebase_storage ^10.2.16 and depends on firebase_storage ^11.0.4, firebase_cached_image is forbidden.
So, because depends on firebase_cached_image ^0.3.1, version solving failed.
I was thinking of adding web caching to your plugin, but wanted to find out why this may not have been implemented already.
I was thinking of altering web_cache_manager.dart to convert the files to base64 for caching in sqflite, and decode from base64 for retrieval... or potentially just using a blob.
I was also thinking of using dart:indexed_db library for a more native web implementation according to this example, where video blobs are stored in the IndexedDB
Any thoughts on this? Web caching is important for my project. Just wanted to get any ideas or thoughts you may have already had before diving in.
Thanks!
Hi everyone, i have a question
With this lib, these photo is cached when app is launched, and when app is kill, the cached is cleared
Or it is stilled cached although app is kill and just only clear if the clear code is called
Thanks
I got The method 'preCache' isn't defined for the type 'FirebaseCacheManager'
await FirebaseCacheManager().preCache(
FirebaseUrl("gs://bucket_f233/profile_pic.jpg"),
);
Versions are as follows
firebase_cached_image : 0.4.2
Flutter 3.0.1 • channel unknown • unknown source
Tools • Dart 2.17.1 • DevTools 2.12.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.