Skip to content
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

Long startup times #23

Open
MrCyjaneK opened this issue May 10, 2023 · 5 comments
Open

Long startup times #23

MrCyjaneK opened this issue May 10, 2023 · 5 comments
Labels
bug Something isn't working feature required Need a new feature

Comments

@MrCyjaneK
Copy link

MrCyjaneK commented May 10, 2023

After adding ~400 images (in total around 1.5GB) of images app startup is long and takes about 5 seconds (there are no images displayed on the screen nor any images are loaded in cache. In fact nothing except

String storageLocation = (await getApplicationDocumentsDirectory()).path;
await FastCachedImageConfig.init(
  subDir: "$storageLocation.imgs-cache",
  clearCacheAfter: const Duration(days: 31),
);

is being done with FastCachedImage library.
After wiping app data and cache everything returns to normal.
I expect to have even more images in cache (more than could possibly fit in ram) and I worry about the startup time and possible crashes. I didn't have that problems with cached_network_image package before.

@volgin
Copy link

volgin commented May 12, 2023

I am not the author of this package, and I have not even tried it yet :), but...

Can you try unawaited instead of await? I imagine the package is indexing all images. 5 seconds seems too long though even for 400 images.

@ghost ghost added feature required Need a new feature bug Something isn't working and removed feature required Need a new feature labels Jul 14, 2023
@ghost
Copy link

ghost commented Jul 14, 2023

I guess we need to do the DB operations in an isolated thread which can improve the performance to an extend

@CHRISTOPANANJICKAL CHRISTOPANANJICKAL added the feature required Need a new feature label Feb 2, 2024
@CHRISTOPANANJICKAL
Copy link
Owner

Im planning to improve the performace issues in a future update. I'm waiting for some other packages to provide web support so that they can be used in this package.

@DanMossa
Copy link

DanMossa commented May 2, 2024

Im planning to improve the performace issues in a future update. I'm waiting for some other packages to provide web support so that they can be used in this package.

Like what package?

@MerdanDev
Copy link
Contributor

I think we need use other way for cache procedures:

  1. Storing a lot of images in hive is not good practice, what can we do for solve this issue is storing all images in file system.

~400 images (in total around 1.5GB)

  1. File system transfer interface speed is kinda doesn't perform well when getting files. What can be solution for it? Storing images in hive, yes, I mean storing in hive if you ask about 1) point, we won't store it always in hive. Loading hive box can be problem when there is so much data that was problem for 1) point.

  2. So after downloading images from network we will store it on file system and hive, and after app closes we need to clear all items from hive(I mean image box). And when after app started again on each file requested we will get from file system and store in hive(memory as Uint8List or byte). This will be solution for 2) point.

In case image was not downloaded form remote:
download image -> save in file system -> save in memory (hive) -> show image;
In case image was downloaded but not in memory:
get from file system -> save in memory -> show image;
In case image was downloaded and saved in memory:
just get from memory -> show image;

1 case will use network traffic
2 case will need file system traffic
3 case will be fastest

There could be memory overflow problem if so many images stored in memory, solution can be limiting memory image count and using it as queue.

Last thing is using key for identification because some url's can be temporary, otherwise url will be key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature required Need a new feature
Projects
None yet
Development

No branches or pull requests

5 participants