MaterialFiles icon indicating copy to clipboard operation
MaterialFiles copied to clipboard

Slow Image Viewer via SFTP

Open mickmack1213 opened this issue 3 years ago • 3 comments

I've scanned through some File Explorers lately and found this one. (Really loving it)

But there is a remarkable performance difference in accessing my SFTP drive compared to some other apps (I'd prefer to not mention them here as they have real shitty privacy)

So I dug a bit deeper this evening and found out. The Image Viewer in this app could probably benifit heavily from Caching, or accessing the same Cache as the main Files Viewer.

My Setup and workflow:

Pixel 4a API31 Emulator in Android Studio connected to my NAS via SFTP:

  1. Inserted a output in sftp/client/FileByteChannel:209:
val length = destination.remaining().coerceAtMost(buffer.remaining())
Log.i("SFTP-perf-testing","read called ${file.path} for $length bytes")
val bufferLimit = buffer.limit()
  1. Opened a remote dir containing 8 fotos
  2. Summed outputs with a very basic python script (This is basically a perfect match to the actual file sizes):
CIMG3114.JPG - 2.21 MB
CIMG3115.JPG - 2.27 MB
CIMG3116.JPG - 2.76 MB
CIMG3117.JPG - 2.10 MB
CIMG3118.JPG - 2.10 MB
CIMG3119.JPG - 1.69 MB
CIMG3120.JPG - 2.08 MB
CIMG3121.JPG - 2.74 MB
  1. Opened the internal Image Viewer and scrolled from the first picture to the last and back again. Got the additional traffic:
CIMG3114.JPG - 3.18 MB
CIMG3115.JPG - 3.18 MB
CIMG3116.JPG - 3.68 MB
CIMG3117.JPG - 3.02 MB
CIMG3118.JPG - 2.10 MB
CIMG3119.JPG - 1.69 MB
CIMG3120.JPG - 3.91 MB
CIMG3121.JPG - 3.48 MB
  1. Closing the Image Viewer does not produce additional traffic and the preview images in the file explorer still show, therefore there must be some kind of cache.

I'm not sure if this can be easily fixed, but loading the actual complete image for the previews in the file explorer and then not using those cached images in the Image Viewer, rather reloading those files again seems rather expensive to me. And a faster user experience would be REALLY nice to me.

I`m not 100% sure if those numbers are perfectly accurate, but those assumptions matched the usage experienced I got when I was browsing my photos with a rather bad Internet connection. First a long wait till those previews were shown and then for every Image in the Image Viewer additional patience was necessary.

mickmack1213 avatar Mar 29 '22 02:03 mickmack1213

If I can help you to solve this, I'd be up to that. I have some programming background, just never worked on an Android App before.

But providing Data and testing shouldn't be a problem

mickmack1213 avatar Mar 29 '22 02:03 mickmack1213

I think I need to pass the correct type to SourceResult in PathAttirbutesFetcher.

zhanghai avatar Mar 30 '22 10:03 zhanghai

Yeah had a look. This seems to be a nice spot.

Forgive me I'm kinda corious. Can you keep me updated about the implementation. I'd love to take a look and learn sth

And feel free to ask for help of any kind

mickmack1213 avatar Mar 30 '22 16:03 mickmack1213