Skip to content

Conversation

yogeshkumawat
Copy link

What this fixes

Prevents crash in LruBitmapPool.put() when a recycled bitmap is passed to the pool.

Why it matters

In rare cases, Glide attempts to pool a bitmap that has already been recycled — often due to race conditions during decode, transformation, or request cancellation. Since isRecycled() throws IllegalStateException, this leads to a fatal crash.

Fix

Add a defensive check and early return if the bitmap is already recycled. This mirrors similar fixes in other parts of Glide (e.g., GifDrawable.draw() crash protection).

Impact

  • ✅ Prevents crash without affecting cache logic
  • ✅ Improves robustness
  • ✅ Compatible with current logic (only avoids pooling invalid bitmaps)

@falhassen
Copy link
Collaborator

The pull request description does not discuss the behavior to change to make bitmapp == null no longer throw an NPE. Are you sure weant to change this?

@falhassen
Copy link
Collaborator

Also, this change needs tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants