PassAndroid icon indicating copy to clipboard operation
PassAndroid copied to clipboard

Scale down images to improve performance

Open sunshinelwj opened this issue 4 years ago • 1 comments

Dear developers,

I found that when I create a passbook, the speed of "opening passbook" is slow.

image image

The reason is that the image I imported is large, which causes the process to cost several seconds to finish. If I imported a small image, the speed of "opening passbook" is fast (less than one second).

I'm curious about the implementation of this part and checked the source code of Passandroid. I found that in the code below, the image I imported is decoded directly. https://github.com/ligi/PassAndroid/blob/master/android/src/main/java/org/ligi/passandroid/model/pass/PassImpl.kt#L69

It is unnecessary to decode the original resolution of added images all the time, reasonable image resizing before decoding can save the time consumption of image decoding and save memory resource. https://developer.android.com/topic/performance/graphics/load-bitmap.html

In addition to the above problem, I found that the image decoding process is executed on the UI thread. However, it is not recommended by Android. https://stuff.mit.edu/afs/sipb/project/android/docs/training/displaying-bitmaps/process-bitmap.html

What’s more, I found that when I import the same image twice, the image decoding process will be repeated execution. I think a simple image cache can avoid this happen.

Do you think what I found will affect Passandroid's runtime performance?

Thanks.

sunshinelwj avatar Feb 23 '21 05:02 sunshinelwj

Yes - you are correct this should be fixed

ligi avatar Apr 03 '21 13:04 ligi