glide icon indicating copy to clipboard operation
glide copied to clipboard

Fix: Prevent crash in LruBitmapPool.put() on recycled bitmap

Open yogeshkumawat opened this issue 5 months ago • 0 comments

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)

yogeshkumawat avatar May 28 '25 09:05 yogeshkumawat