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

Listdir takes so much time if directory has data more then 3k entries. #605

Open
adeel399 opened this issue Sep 15, 2023 · 2 comments
Open

Comments

@adeel399
Copy link

Bug Report

Problem

What is expected to happen?

What does actually happen?

Information

I made a local gallery in my app and everything works but one directory whatsapp images have total 154000 images inside it and listdir takes 1 minutes or more to give me all entries array ..

Command or Code

Environment, Platform, Device

Version information

Checklist

  • [yes ] I searched for existing GitHub issues
  • [yes ] I updated all Cordova tooling to most recent version
  • [yes ] I included all the necessary information above
@breautek
Copy link
Contributor

154k files in a single directory? ouff...

I'm not sure if you're working with android or iOS but on android I'm curious how much time is spent at listFiles or if the bottleneck is mostly in the cordova bridge.

I believe the iOS equivilant is here

If the bottleneck is at the native API level on iOS, I'm not sure if there is anything that can be done, as far as I can tell iOS doesn't offer any stream API other than NSDirectoryEnumerator which will do a deep recursive traversal (which isn't what we want)

For Android, there is a DirectoryStream API but it's an API 26+ API so it's not something that can be used yet... as cordova needs to support API 24.

If the bottleneck is at the bridge, then introducing a stream read API might be possible so you don't need to transfer the entire dataset of 154k file entries in one API response, but I personally don't have time to allocate introducing such feature.

@adeel399
Copy link
Author

I am working on android ,i am thinking of any option to limit the number of entries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants