glide v4.4.0 Release Notes

Release Date: 2017-12-04 // over 6 years ago
  • ๐Ÿš€ 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 called clearOnDetach() 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 called waitForLayout() that simplifies the previous mechanism for forcing Glide's ViewTargets 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 after onDestroy of the corresponding Activity or Fragment (#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 GifDrawables could continue to animate after clear() or onStop() (#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 using onlyRetrieveFromCache (#2428, 108a062)
    • ๐Ÿ›  Fixed a couple of cases where calling load(Bitmap) or load(Drawable) could cause Glide to re-use or recycle the given Bitmap or Drawable (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 a GlideModule 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 and ReferenceQueue if the Targets 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:

    @Overridepublic void applyOptions(Context context, GlideBuilder builder) { builder.setIsActiveResourceRetentionAllowed(false); }
    

    Glide.with(fragment).load() and Glide.with(fragment).asDrawable().load() now behave identically. Previously Glide.with(fragment).asDrawable().load() would apply some specific options based on the type of the model provided to load(), but Glide.with(fragment).load() would not. Now both behave identically (8613292).

    Calling RequestBuilder.load(byte[]) will no longer override previously set DiskCacheStrategy and skipMemoryCacheOptions options (c7b7dfe).

    ๐Ÿ’ฅ Breaking Changes

    • โœ… The RequestManager.load(Object) method has been augmented with the same type specific overloads that are available on RequestBuilder. Unfortunately this may break some tests that mock the return value of RequestManager.load(). Typically those breakages can be resolved by casting:

      when(requestManager.load((Object) any())).thenReturn(requestBuilder);

    โœ… Or if you're passing in null as your model in your tests:

     when(requestManager.load((Object) null)).thenReturn(requestBuilder);
    

    Or if you have a specific type for your model:

     when(requestManager.load(any(Uri.class))).thenReturn(requestBuilder);
    

    โœ… Or if your test has a specific type, but your production code uses an Object:

    // 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() in GlideBuilder in favor of setSourceExecutor() (6837543)
    • ๐Ÿ—„ Deprecated ArrayPool.put(Array, Class<Array>) in favor of ArrayPool.put(Array) (b4d778b)
    • ๐Ÿ—„ Deprecated the constructor in ViewTarget that accepts a boolean waitForLayout parameter in favor of the waitForLayout() method on ViewTarget (05b8854).