google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
481 stars 255 forks source link

itemMediaView image flicker when loading image #2649

Open FikriMilano opened 1 month ago

FikriMilano commented 1 month ago

Describe the bug itemMediaView image flicker when loading image.

Component SDC library

To Reproduce Steps to reproduce the behavior:

  1. Have a questionnaire that loads image using itemMedia
  2. Open it

Expected behavior Should not flicker.

Video

blinking_imageview.webm

Smartphone (please complete the following information):

Additional context N/A

Would you like to work on the issue? Yes

FikriMilano commented 1 month ago

I think the easiest way is to revert back to:

imageAttachment.setImageBitmap(image)

I've tried to fix Glide itself by following these tickets below, but none works: https://github.com/bumptech/glide/issues/755 https://github.com/bumptech/glide/issues/527

MJ1998 commented 1 month ago

I suspect it could be because of the reason in this comment which says

The flickering is caused by you loading images into the same view in quick succession.

Maybe the bind function is being called unnecessarily in quick succession? Not sure if that is solvable but can you investigate ? Thanks @FikriMilano

jingtang10 commented 1 month ago

I think the easiest way is to revert back to:

imageAttachment.setImageBitmap(image)

I've tried to fix Glide itself by following these tickets below, but none works: bumptech/glide#755 bumptech/glide#527

why did we use glide in the first place?

i think what's happening is reflow caused by glide loading up the image after thee text is loaded.

a potential fix (i'm not saying it's better) to consider is reserving the space on screen so that the text doesn't get moved down - this would probably alleviate the blinking effect.

if we remove the use of glide here, should we remove it as a dependency? do we use it elsewhere?