-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Feature] Be able to read the gallery as fast as the native IOS #579
Comments
@Tom3652 It all depends on the implementation as I've learned the hard way. If you could share any code, it'd be helpful to see if we could give you any pointers on how to make it faster. |
@jaysignorello thank you for your reply and your help in advance, here is the code i am using to display the assets :
These items are displayed in a simple The result is the same if i use 500 seems high for a thumbnail but on IOS the quality is really lowered if it's not set to such value, compared to the IOS Gallery once again |
@Tom3652 thanks, that's helpful. Likely, the reason for the flickering is because the
|
Thanks for the detailed tips !
Thanks again for your time |
@Tom3652 Glad to hear that There is never a stupid question. The size you'll be looking to calculate is the thumbnail. If say your using a grid and each grid item is 75x75, you'll need to increase the size of the thumbnail to match the To accomplish that, you'll get Size gridSize = Size(75,75);
double devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
Size thumbSize = Size(gridSize.width * devicePixelRatio, gridSize.height * devicePixelRatio)
...
GalleryThumbnail(asset: asset, index: 1, thumbSize: thumbSize) Regarding the caching, you'd call it before you'd render the assets for the user. You won't want to walk through their entire library and precache ever image. Instead for example, as the user is scrolling, you might pull the assets earlier than you are now, then kick off doing the precache, and start loading the assets into the UI. This is obviously advanced and will require a good deal of work to get right, but it's most certainly what Apple is doing to help make their experiences smooth. |
Thanks again @jaysignorello it helps a lot for performances ! I will try to implement the caching system. So far, it's already much better than what i had, but if i scroll very fast i still have blank space for like 200ms the time the Here is the "normal output" : I am trying to do something like this with the cache system you provide :
The return of I am storing myself the
Here is the result : I will do better maths to avoid having 5k+ thumb in memory, but around 200-300 all the time by recycling the |
@Tom3652 That's great.
While your approach might work alright in a non-release/dev setting, I wouldn't recommend it. The problem is that you need to be careful about your apps memory usage and make sure it's a good citizen. iOS for example will kill your app if it's consuming too much memory, so it's important to be mindful of that. For caching implementation, I'd suggest checking out existing solutions such as https://pub.dev/packages/flutter_cache_manager or if you want to roll your own, adopting a LRU cache implementation so you're limiting the number of objects in memory at once to ones that have been recently used. |
@Tom3652 and oh, seems like we can close out this ticket now. |
Thanks again for the useful links and the help, yes i am aware about the memory issue and will not release something like this. |
Thanks for all these solid solutions for the performance. |
Thanks for the API !
Is your feature request related to a problem? Please describe.
When you scroll down in the IOS native gallery, you never see any jank or blinking for any photo.
Not sure the issue is related to the plugin though, but i am loading thumbnails from memory and they are all blinking on both Android and IOS with white placeholders.
I have checked the performances of retrieving assets and it seems very fast actually, the problem doesn't come from the retrieval of assets but rather in UI.
Describe the solution you'd like
If you know how to load assets in a way that everything seems always preloaded, you could make a simple Widget that takes care of this.
If you want to let this API be without UI, can you provide in the documentation an example of what you would do in your app to have a similar gallery as the native IOS (not talking about Staggered grid, but simply removing blinking) ?
Describe alternatives you've considered
If this is not possible with the plugin, i am considering doing it natively (Swift) because it works perfectly on IOS (and i have 5K+ photos / videos on my phone, without any blinking and even with a very good resolution)
I guess the same on Android.
But again, the problem is a UI problem, not from the plugin but since i can't find a solution with Flutter
Widgets
...The text was updated successfully, but these errors were encountered: