Glide v5.0.8
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
compileSdkVersionto 37 and Robolectric to 4.16.1. - Bump Glide
minSdkVersionto 23 to match AndroidX requirements. - Restore deterministic module sorting in Glide annotation processors to improve build reproducibility (Fixes #5657).
- Fix Javadoc style issue in
setMemoryCategoryInBackgroundthat was breaking Renovate tooling (Fixes #5680). - Fix PMD violations in
Glide.javaandGlideExecutor.java(AccessorMethodGeneration and RedundantFieldInitializer). - Fix fragile use of
TypeMirror#toStringin 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
ImageDecoderwith certain input streams or whenArrayPoolbuffer allocation was enabled. - Unbounded Allocations: Fixed unbounded memory allocations when decoding bitmaps from
InputStreamsource types. - Buffer Pooling: Added support for allocating
ImageDecoderByteBuffers via Glide'sArrayPoolto avoid double-allocation overhead (enabled viasetUseArrayPoolForImageDecoderByteBufferAllocation). - Direct Uri Decoding: Direct decoding of Bitmaps from Uris using
ImageDecoderis now supported.
To enableImageDecoderin your application, configure the options in yourAppGlideModuleaccordingly:
@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
UriBitmapImageDecoderResourceDecoderto allow direct decoding of Bitmaps from Uris using Android'sImageDecoder. - 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
DiskLruCacheto reduce retained memory. - ImageDecoder Buffer Pooling: Add
ImageDecoderByteBuffer allocation viaArrayPoolto avoid double-allocation overhead (flag-guarded byUseArrayPoolForImageDecoderByteBufferAllocation). - Fix Unbounded Allocations: Fix unbounded bitmap allocations in Glide
ImageDecoderwhen usingInputStream(flag-guarded byUseHeapBufferForImageDecoderWithInputStream). - ImageDecoder OOM/ANR Fix: Reject unknown stream formats in
InputStreamBitmapImageDecoderResourceDecoder.handlesto prevent OOMs/ANRs whenArrayPoolis enabled. - Resource Leak Fix: Fix resource leak in
ByteBufferUtil.fromStreamby ensuring buffers fromArrayPoolare returned on exception. - Picker URI Support: Update
isAndroidPickerUrito support new picker URI variations (likepicker_get_content/andpicker_transcoded/). - Memory Tracking Logs: Add "GlideMemoryTracking" debug tag to trace memory overhead from scaling and cache hits.
- Experimental Downsample Strategy: Add experimental option
setCenterInsideAsDefaultDownsampleStrategytoGlideBuilderto allow usingCENTER_INSIDEas the default downsampling strategy.
Full Changelog: v5.0.7...v5.0.8