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

Crash on startup because of updateGalleryThumb() and 5k+ images in DCIM directory #54

Closed
frikisama opened this issue Sep 14, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@frikisama
Copy link

Describe the bug
With LineageOS 18.1 (Android 11) on a OnePlus 7 Pro, when there is a great amount of pictures in the DCIM directory (5k+ in my case), the application crashes on startup. This is caused by the application scanning ALL image files in that directory on startup to create the thumbnails for the gallery while building the Camera fragment.

The cameraFragmentViewModel.updateGalleryThumb(); call in the onResume() method in src/main/java/com/particlesdevs/photoncamera/ui/camera/CameraFragment.java takes several minutes in this case, and the application crashes after finishing.

To Reproduce
Steps to reproduce the behavior:

  1. Have a sizable amount of pictures on a LineageOS 18.1 / Android 11 phone
  2. Launch Photon Camera
  3. Wait
  4. Wait...
  5. Crash

Expected behavior
The application starts up. Maybe first boot takes longer. Maybe gallery startup takes longer.

Logs
https://gist.github.com/frikisama/ff78255ff0a6ca731f705ed2c04df9e4

Smartphone (please complete the following information):

  • Device: OnePlus 7 Pro
  • OS: LineageOS
  • Version: 18.1 - latest build

Additional context
The background could be the slow FS access on Android 11. See here for example: syncthing/syncthing-android#1630
Or here: https://www.reddit.com/r/androiddev/comments/kpn68k/android_11_very_slow_file_access_performance/

Bypassing the scanning on startup lets the application start, but it crashes getting into the gallery. Putting this in a background thread could help. Maybe a cache could help with the UX side of things, in this case. An option to use an external gallery app could be used as a workaround.

@frikisama
Copy link
Author

This patch works around this issue: https://gist.github.com/frikisama/ff736e69be0a8732735fc34477ab25a8

Work needs to be done around gallery image loading and thumbnailing, as it reads the whole directory every time, but the application itself can start even with a high amount of images in the DCIM directory on Android 11, and simply becomes unbearably slow when working with the gallery.

@eszdman eszdman added the bug Something isn't working label Sep 16, 2021
@eszdman
Copy link
Owner

eszdman commented Sep 16, 2021

Thanks for the bug report, I will take into account that there is such a bug.

@eszdman eszdman closed this as completed Sep 18, 2021
@xlucn
Copy link

xlucn commented Nov 29, 2021

(Edited)

Still happening to me. I had 2000+ images in DCIM folder, and it uses ~10 seconds to start or switch views. Guess it's less than 5000+ and it's just slow rather than crash?

The phone is Oneplus 8. OS is LineageOS 18.1. PhotonCamera is v0.8.12381.

@xlucn
Copy link

xlucn commented May 22, 2022

I went through a quite bit to build the latest dev branch (reporting v0.8.14951), and confirm it's not freezing or crashing for me!

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

No branches or pull requests

3 participants