RedReader icon indicating copy to clipboard operation
RedReader copied to clipboard

Suggestion for improving image loading

Open struggggle opened this issue 8 years ago • 3 comments

Dear developers,

I am a user of RedReader, and thank you for the wonderful work.

When I click an item and browse it's image, for some large images, the downloading process will take a long time. For example, the situation below can consume more than 10 seconds:

20170326142421

In many cases images are larger than required. Android documentation suggests us to resize the image according to the size of the UI component that displays it. By properly resizing image before downloading and decoding, we can save memory resource and make app run more smoothly, which can provide users with a better experience. https://developer.android.com/topic/performance/graphics/load-bitmap.html#read-bitmap

I noticed that in the following code, image resizing is correctly applied: org.quantumbadger.redreader.views.imageview.ImageTileSourceBitmapRegionDecoder.java getTile() https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/views/imageview/ImageTileSourceBitmapRegionDecoder.java#L75

However, in the code below, images are decoded directly without resizing: org.quantumbadger.redreader.activities.ImgurUploadActivity.java (line number 213) https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/activities/ImgurUploadActivity.java#L213

org.quantumbadger.redreader.adapters.AlbumAdapter.java (line number 157) https://github.com/QuantumBadger/RedReader/blob/master/src/main/java/org/quantumbadger/redreader/adapters/AlbumAdapter.java#L157

I am not familiar with the source code of RedReader, so I am not sure whether the code listed above corresponds to the situation I described. However, whether it is or not, I think they all need to be optimized.

Do you think image resizing will improve RedReader' performance? If yes, perhaps resizing image before downloading can make RedReader more smooth in user interaction.

Looking forward to your response.

Thanks.

struggggle avatar Mar 26 '17 07:03 struggggle

Thanks for the suggestion!

When the loading circle is displayed, the image is being downloaded, rather than decoded. The decoding only starts when the image is fully downloaded, and usually takes a few milliseconds at most.

The downloading is the time-consuming part, but obviously that isn't affected by resizing locally -- that just depends on the file size of the image on the remote server.

Some sites (such as imgur) allow you to download lower resolution images, so that would be one way to save time (and bandwidth). There's another ticket open for this here:

https://github.com/QuantumBadger/RedReader/issues/250

QuantumBadger avatar Mar 26 '17 08:03 QuantumBadger

@QuantumBadger Thanks for your reply.

I agree with you. The downloading is the main part of time consumption when I browse an image for the first time.

I know you have implemented image cache in RedReader. When I click on an item again, image displaying will not contain the downloading process. For some small images, the decoding process is fast and app runs smoothly. However, for some large images (for example, an image whose size is 5MB (2480*3508px)), I can feel an obvious delay about one to two seconds. For this case, I think resizing image properly can make app run faster. What's more, image resizing can reduce the risk of OOM for the case that there is little remaining memory available.

Maybe that is the thing we can do now.

struggggle avatar Mar 27 '17 13:03 struggggle

Just started trying RedReader and I felt loading to be a little jarring.

It feels like loading of Posts view blocks on fetching media like image thumbnails -- is this the case?

While blocking on text fetch is unavoidable, fetching media asynchronously would make for a smoother experience.

Kache avatar Jul 06 '21 20:07 Kache