Skip to content

Glide v5.0.8

Choose a tag to compare

@falhassen falhassen released this 11 Jul 00:57
93b4f47

Compose

N/A

KTX

N/A

Build Changes

  • Upgrade Glide build system to Gradle 9.4.1, AGP 8.8.0, and Kotlin/KSP 2.0.20, resolving various build and test compatibility issues.
  • Bump Glide compileSdkVersion to 37 and Robolectric to 4.16.1.
  • Bump Glide minSdkVersion to 23 to match AndroidX requirements.
  • Restore deterministic module sorting in Glide annotation processors to improve build reproducibility (Fixes #5657).
  • Fix Javadoc style issue in setMemoryCategoryInBackground that was breaking Renovate tooling (Fixes #5680).
  • Fix PMD violations in Glide.java and GlideExecutor.java (AccessorMethodGeneration and RedundantFieldInitializer).
  • Fix fragile use of TypeMirror#toString in annotation compiler.
  • Update tests to run on API 24.

Changes

ImageDecoder Support

It should be safer to use Android's ImageDecoder (introduced in Android 9.0 Pie / API 28) with Glide on Android Q (API 29) and above. Please consider trying it out, as ImageDecoder is the now preferred mechanism for decoding images in Android and may yield performance and memory usage benefits.

Several critical issues have been resolved in this release:

  • OOM/ANR Fixes: Fixed potential OutOfMemory (OOM) errors and Application Not Responding (ANR) issues when using ImageDecoder with certain input streams or when ArrayPool buffer allocation was enabled.
  • Unbounded Allocations: Fixed unbounded memory allocations when decoding bitmaps from InputStream source types.
  • Buffer Pooling: Added support for allocating ImageDecoder ByteBuffers via Glide's ArrayPool to avoid double-allocation overhead (enabled via setUseArrayPoolForImageDecoderByteBufferAllocation).
  • Direct Uri Decoding: Direct decoding of Bitmaps from Uris using ImageDecoder is now supported.
    To enable ImageDecoder in your application, configure the options in your AppGlideModule accordingly:
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
  @Override
  public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    // Enable ImageDecoder for Bitmaps (Android Q+)
    builder.setImageDecoderEnabledForBitmaps(true);

    // Enable ImageDecoder for Uris (Android Q+)
    builder.setUriImageDecoderEnabled(true);
    
    // Enable optimized buffer pooling for ImageDecoder
    builder.setUseArrayPoolForImageDecoderByteBufferAllocation(true);
    
    // Use heap buffers for ImageDecoder with InputStreams to avoid native memory overhead
    builder.setUseHeapBufferForImageDecoderWithInputStream(true);
  }
}
  • Direct Uri Decoding: Implement UriBitmapImageDecoderResourceDecoder to allow direct decoding of Bitmaps from Uris using Android's ImageDecoder.
  • Direct Memory Decoding: Support direct memory decoding for byte buffers and arrays without stream wrapping.
  • HEIF/HEIC Detection: Add HEIF/HEIC format detection to DefaultImageHeaderParser.
  • Disk Cache Path Memoization: Add a setting to disable disk cache path name memoization in DiskLruCache to reduce retained memory.
  • ImageDecoder Buffer Pooling: Add ImageDecoder ByteBuffer allocation via ArrayPool to avoid double-allocation overhead (flag-guarded by UseArrayPoolForImageDecoderByteBufferAllocation).
  • Fix Unbounded Allocations: Fix unbounded bitmap allocations in Glide ImageDecoder when using InputStream (flag-guarded by UseHeapBufferForImageDecoderWithInputStream).
  • ImageDecoder OOM/ANR Fix: Reject unknown stream formats in InputStreamBitmapImageDecoderResourceDecoder.handles to prevent OOMs/ANRs when ArrayPool is enabled.
  • Resource Leak Fix: Fix resource leak in ByteBufferUtil.fromStream by ensuring buffers from ArrayPool are returned on exception.
  • Picker URI Support: Update isAndroidPickerUri to support new picker URI variations (like picker_get_content/ and picker_transcoded/).
  • Memory Tracking Logs: Add "GlideMemoryTracking" debug tag to trace memory overhead from scaling and cache hits.
  • Experimental Downsample Strategy: Add experimental option setCenterInsideAsDefaultDownsampleStrategy to GlideBuilder to allow using CENTER_INSIDE as the default downsampling strategy.

Full Changelog: v5.0.7...v5.0.8