Glide 4.4.0
This is the November release of Glide.
Features
- Updated Glide's generated API to allow RequestOptions return values and avoid a bunch of
@CheckResult
warnings (e78f2ee, 7fccb32) - Enabled cache sizes >
Integer.MAX_VALUE
(d402780, thanks to @bhargavms) - Added an API to
ViewTarget
calledclearOnDetach()
that allows you to optionally clear and restart requests when the corresponding view is detached and reattached to its window (#2520, d0fd967):Glide.with(fragment) .load(url) .into(imageView) .clearOnDetach();
- Added an API to
ViewTarget
calledwaitForLayout()
that simplifies the previous mechanism for forcing Glide'sViewTargets
to wait for a layout pass before determining the size of the view they wrap (05b8854):Glide.with(fragment) .load(url) .into(imageView) .waitForLayout();
- Added a MockGlideExecutor that could be used as part of a future testing compat library (6cee6d2, thanks to azlatin@)
- Added an API to specify a custom executor to use when decoding GIF frames (6837543)
Bugs
- Improved trimming behavior with inconsistent resource sizes (#2550, thanks to @unverbraucht)
- Fixed overly aggressive escaping of some valid characters in http urls (#2583, 014bf44)
- Added a direct dependency on support-fragment in Glide's pom (#2547, c1c9be2)
- Fixed an issue where dereferencing a
Target
without clearing it would result in the loaded resource never being returned to Glide's memory cache (#2560, 0209662, 7e317c0) - Fixed an IllegalStateException when
RequestManagers
are memoized and then used to start a new load afteronDestroy
of the correspondingActivity
orFragment
(#2262, 8119837) - Fixed an NPE when using GifDrawables as thumbnails due to a bug that can fail to clear thumbnails in
onStop()
(#2555, 9c82c42) - Fixed a
SecurityException
on some devices when trying to register a connectivity receiver (#1417, 6bc908b) - Fixed a
SecurityException
on some devices when trying to obtain connectivity status (#1405, bcd6cc2) - Fixed a couple of cases where
GifDrawable
s could continue to animate afterclear()
oronStop()
(#1087, 3dad449, 9d87dea) - Improved decode times for GIF frames on earlier versions of ART and some lower end devices by up to 40% (#2471, e7a4942, fa2ebfe, 7c0cd63, 4db20db, 65e5506)
- Eliminated a few unnecessary object allocations in Glide's request path (b4d778b)
- Fixed an issue on some devices where
ExternalPreferredCacheDiskCacheFactory.java
might attempt (and fail) to use external storage if the external storage directory exists but isn't writable (#2641, 5580e51, thanks to @anpez) - Ensure that requests started with
onlyRetrieveFromCache
don't block on already running equivalent requests that aren't usingonlyRetrieveFromCache
(#2428, 108a062) - Fixed a couple of cases where calling
load(Bitmap)
orload(Drawable)
could cause Glide to re-use or recycle the givenBitmap
orDrawable
(cff4f2c). - Fixed a bug where the disk cache could become unusable until apps are restarted if the system clears the cache directory while the app is open and the app calls
DiskCache.clear()
(#2465, 16eaa9b). - Fix a crash attempting to log a recycled Bitmap's size in Glide's
BitmapPool
pre-filling APIs (#2574, 7387298) - Fixed an error log "Expected to receive an object of but instead got null" when restarting requests with thumbnails where the thumbnail previously completed after the full request (a1e3fa2)
- Fixed a compilation error when compiling with
kapt
and-Dkotlin.compiler.execution.strategy="in-process"
while using aGlideModule
with the@Excludes
annotation.
Behavior Changes
-
Resources loaded into Targets outside of Activity/Fragment lifecycles (ie with the Application Context) will be returned to Glide's caches via a
WeakReference
andReferenceQueue
if theTarget
s are dereferenced without being cleared. Previously dereferencing these Targets would simply allow the underlying resource to be garbage collected, which could lead to unexpected cache misses (#2560). Transient memory usage may increase for applications that regularly dereference Targets without clearing them as the resources are now re-captured instead of being immediately and unexpectedly garbage collected.To disable this behavior, in an AppGlideModule, call setIsActiveResourceRetentionAllowed:
@Override public void applyOptions(Context context, GlideBuilder builder) { builder.setIsActiveResourceRetentionAllowed(false); }
-
Glide.with(fragment).load()
andGlide.with(fragment).asDrawable().load()
now behave identically. PreviouslyGlide.with(fragment).asDrawable().load()
would apply some specific options based on the type of the model provided toload()
, butGlide.with(fragment).load()
would not. Now both behave identically (8613292). -
Calling
RequestBuilder.load(byte[])
will no longer override previously setDiskCacheStrategy
andskipMemoryCacheOptions
options (c7b7dfe).
Breaking Changes
- The
RequestManager.load(Object)
method has been augmented with the same type specific overloads that are available onRequestBuilder
. Unfortunately this may break some tests that mock the return value ofRequestManager.load()
. Typically those breakages can be resolved by casting:Or if you're passing inwhen(requestManager.load((Object) any())).thenReturn(requestBuilder);
null
as your model in your tests:Or if you have a specific type for your model:when(requestManager.load((Object) null)).thenReturn(requestBuilder);
Or if your test has a specific type, but your production code uses an Object:when(requestManager.load(any(Uri.class))).thenReturn(requestBuilder);
// In tests: String url = ... when(requestManager.load((Object) eq(url))).thenReturn(requestBuilder); // In prod code: Object url = ... requestManager.load(url).into(imageView);
Deprecations
- Deprecated void return values for
@GlideOption
and@GlideType
annotated methods (e78f2ee, 7fccb32) - Deprecated
DiskLruCacheWrapper.get()
in favor of a static factory method (1cfc4af) - Deprecated
setResizeExecutor()
inGlideBuilder
in favor ofsetSourceExecutor()
(6837543) - Deprecated
ArrayPool.put(Array, Class<Array>)
in favor ofArrayPool.put(Array)
(b4d778b) - Deprecated the constructor in
ViewTarget
that accepts a booleanwaitForLayout
parameter in favor of thewaitForLayout()
method onViewTarget
(05b8854).