Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gifs appear in multiple views when start/stopped #2526

Closed
charlesdurham opened this issue Oct 29, 2017 · 2 comments
Closed

Gifs appear in multiple views when start/stopped #2526

charlesdurham opened this issue Oct 29, 2017 · 2 comments
Labels
Milestone

Comments

@charlesdurham
Copy link

charlesdurham commented Oct 29, 2017

Noticed an issue where gifs seem to duplicate when going from stopped to started state across multiple gifs see Video.

  • glide 4.2
  • Android 7.1 and 8.0

Issue seems to go away with Glide.get(context).bitmapPool.setSizeMultiplier(0f).

I think I've identified the issue; GifDrawable is stopped and removes its frame loader callback during a frame load (after GifFrameLoader.loadNextFrame()). Eventually, the GifFrameLoader is going to get one last onFrameReady callback and it will attempt to notify its listeners but since the GifDrawable is already removed nothing happens, however the previous Bitmap, which in this case is still being used by the GifDrawable is cleared and put into the cache.

I've got some sample code that I was able to reproduce with by quickly stopping the gifs and starting the others:

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val iv1 = findViewById<ImageView>(R.id.imageView1)
    val iv2 = findViewById<ImageView>(R.id.imageView2)

    val glide = Glide.with(this)

    glide
        .load("https://media.giphy.com/media/l2YWEhwRvpY4Q6UJG/giphy.gif")
        .into(iv1)

    glide
        .load("https://media.giphy.com/media/muVfdK4fmamek/giphy.gif")
        .into(iv2)

    iv1.setOnClickListener {
      val drawable = iv1.drawable as GifDrawable
      if (iv1Playing) {
        drawable.stop()
        iv1Playing = false
      } else {
        drawable.start()
        iv1Playing = true
      }
    }

    iv2.setOnClickListener {
      val drawable = iv2.drawable as GifDrawable
      if (iv2Playing) {
        drawable.stop()
        iv2Playing = false
      } else {
        drawable.start()
        iv2Playing = true
      }
    }
  }
@sjudd
Copy link
Collaborator

sjudd commented Oct 30, 2017

Thanks for the detail, video and repro steps, super helpful. I believe this is fixed. You can verify by trying with the latest snapshot: http://bumptech.github.io/glide/dev/snapshots.html#obtaining-snapshots

@charlesdurham
Copy link
Author

charlesdurham commented Oct 31, 2017

Looks great, thanks 👍

sjudd added a commit to sjudd/glide that referenced this issue Nov 3, 2017
-------------
Avoid blocking Futures forever on unexpected load failures.

-------------
Add a system for emulator based regression testing.

The tests can both generate canonical output specific to one
or more Android SDKs and compare the current output to previously
generated images to detect regressions.

Ideally we can add top level tests for most Glide functionality
using these tests to detect regression across the library without
a ton of overhead either when new tests are added or when
functionality is intentionally.

-------------
Add an explicit 2m timeout to Firebase sample tests.

-------------
Run emulator tests on all available Android versions on Firebase.

-------------
Run instrumentation tests on Travis always.

This should help us keep track of flakes so they don’t only appear
when someone makes a pull request.

-------------
Remove Android API 20 emulator from travis.

It’s unreliable and basically just KitKat anyway.

-------------
Update usage script for split_by_sdk.

-------------
Add more transformation regression tests.

-------------
Avoid clearing Bitmaps in use by paused GifDrawables.

Fixes bumptech#2526.

-------------
clear all pixels when dispose is 3 but previousImage is null (bumptech#2521)

* clear all pixels when dispose is 3 but previousImage is null

* Separate conditions and explain why we need to drop the prev image

* release previousImage for re-use

-------------
Created by MOE: https://github.com/google/moe

MOE_MIGRATED_REVID=e86fd41e16aac1b95884494c1097417b4ab15a5a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173974844
sjudd added a commit to sjudd/glide that referenced this issue Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants