Skip to content

ImageView briefly losing the image only on 4.14.2 (produces a flicker) #4958

@sky-ricardocarrapico

Description

@sky-ricardocarrapico

Glide Version: 4.14.2

Integration libraries: OkHttp 4.9.0

Device/Android Version: Reproducible in any device

Issue details / Repro steps / Use case background:

Since we've upgraded to 4.14.2, we've been having an issue where, briefly, the ImageView loses the image. This will make its size be 0x0 (we're using wrap_content for this specific view) and it'll produce a flicker.

I recorded a video highlighting the problem:
https://user-images.githubusercontent.com/67684386/202150949-fd0cc824-b35f-4ae9-9a91-ac359e171958.mp4

The video shows that we had no image (haven't been loaded yet), then it loads and show, then it disappears, then it shows again.

We're loading the image in a RecyclerView (no compose at all here) and there's multiple rebinds happening at that time, so it could be related.

From debugging we could track this down into loading the image with properties on the RequestBuilder that are actually a new instance. Such as:

.transition(DrawableTransitionOptions.withCrossFade(crossFadeFactory))
or
.listener(listener)

Not calling those methods on RequestBuilder fixes the problem.

A very important detail is that this does not happen on 4.14.1, which makes me very suspicious of this commit f3d6ff7. In the meantime we had to rollback to this version.

Glide load line / GlideModule (if any) / list Adapter code (if any):

requestBuilder
    .listener(listener)
    .transition(DrawableTransitionOptions.withCrossFade(crossFadeFactory))
    .skipMemoryCache(config.skipMemoryCache)
    .diskCacheStrategy(config.cacheStrategy)
    .into(this)

This code will be called multiple times in the rebind of a ViewHolder.

Layout XML:

<ImageView
        android:id="@+id/pdp_title_logo_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/pdp_title_margin_vertical"
        android:adjustViewBounds="true"
        android:maxWidth="@dimen/pdp_title_frame_width"
        android:maxHeight="@dimen/pdp_title_frame_height"
        android:scaleType="fitStart"
        android:visibility="gone"
        app:layout_constraintDimensionRatio="1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toStartOf="@id/guide_start"
        app:layout_constraintTop_toBottomOf="@id/pdp_channel_logo_img"
        tools:srcCompat="@drawable/ic_app_logo_small"
        tools:visibility="visible" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions