glide icon indicating copy to clipboard operation
glide copied to clipboard

Glide forces a full screen redraw when using a placeholder

Open domutadarius opened this issue 1 year ago • 0 comments

Issue: I am using the advanced developer option that flashes the view that is drawn with a red overlay. This option is different from the one that flashes the whole screen when a view updates, so no mistake was made.

My issue is that that the whole screen gets redrawn when the image updates, creating high green bars when using the "Profile HWUI" option. This only happens when a placeholder is used such that the images switch pretty fast. If I disable the placeholder and the image clearing and I apply a custom loader that only sets the image view drawable, then only the image view gets redrawn.

My context is that I am trying to improve the performance of a really old and slow Android device that is drastically affected by image loading. Profiling it with the HWUI tool showed huge improvements when the placeholder is disabled such that only the image is redrawn, as the green lines stay down.

Implementation notes:

  1. Using Glide's standard loader ".into(imageView)" always triggers a full screen redraw.
  2. Using a custom loader that only sets the image drawable like in the attached gist fixes this issue, but only under the condition that no placeholders and no image clearing is being used.

Glide Version: com.github.bumptech.glide:glide:4.16.0

Code Gist: https://gist.github.com/domutadarius/98021d5e44b9ef02dddd2e796e60bc5b

With Placeholder and target clearing:

https://github.com/user-attachments/assets/527371a8-771d-43d2-9113-d9ed9ff4e7bb

With NO placeholder and NO target clearing + custom view loader:

https://github.com/user-attachments/assets/302bf55d-2983-498f-abc7-6496b2987a2f

Performance comparison (Watch the green bars):

Whole screen redraw: whole-screen-redraw-proof

Single image redraw: Single-image-redraw-proof

UPDATE:

I commented out the placeholders both in the glide load request and in the custom loader. To achieve the placeholder effect I did two loads: One with a transparent drawable and one with an actual image and I achieved limited image view redraw. So, it seems like there's an issue with the Glide placeholder:

https://github.com/user-attachments/assets/d1d5ff16-2753-417f-acdc-f3b6771e93c2

domutadarius avatar Nov 15 '24 07:11 domutadarius