Skip to content

Nuke 6.0 🏎

Compare
Choose a tag to compare
@kean kean released this 23 Dec 16:40
· 2548 commits to main since this release

About 8 months ago I finally started using Nuke in production. The project has matured from a playground for experimenting with Swift features to something that I rely on in my day's job.

There are three main areas of improvements in Nuke 6:

  • Performance. The primary loadImage(with:into:) method is now 1.5x faster thanks to cumulative performance improvements to CancellationToken, Manager, Request and Cache. And it's not just main thread performance, many of the background operations were also optimized.
  • API refinements. Some common operations that were surprisingly hard are easy now. And there the implementation details are no longer leaking into a public API (e.g. classes like Deduplicator).
  • Fixed inconveniences like Thread Sanitizer warnings (false positives!). Improved compile time. Better documentation.

New APIs

  • Implements progress reporting #81
  • Scaling images is now easier and more discoverable with new convenience Request initialisers (Request.init(url:targetSize:contentMode: and Request.init(urlRequest:targetSize:contentMode:)
  • Add a way to add anonymous image processors to the request (Request.process(key:closure:) and Request.processed(key:closure:))
  • Add Loader.Options which can be used to configure Loader (e.g. change maximum number of concurrent requests, disable deduplication or rate limiter, etc).

Improvements

  • Improve CancellationTokenSource, Loader, TaskQueue, Manager, Request, Cache performance
  • Parallelize image processing for up to 2x performance boost in certain scenarios. Might increase memory usage. The default maximum number of concurrent tasks is 2 and can be configured using Loader.Options.
  • Loader now always calls completion on the main thread
  • Move URLResponse validation from DataDecoder to DataLoader
  • Make use of some Swift 4 feature like nested types inside generic types
  • Improve compile time
  • Wrap Loader processing and decoding tasks into autoreleasepool which reduced memory footprint

Fixes

  • Get rid of Thread Sanitizer warnings in CancellationTokenSource (false positive)
  • Replace Foundation.OperationQueue & custom Foundation.Operation subclass with a new Queue type. It's simpler, faster, and gets rid of pesky Thread Sanitizer warnings #141

Removed APIs

  • Remove global loadImage(...) functions #142
  • Remove static Request.loadKey(for:) and Request.cacheKey(for:) functions. The keys are now simply returned in Request's loadKey and cacheKey properties which are also no longer optional now.
  • Remove Deduplicator class, make this functionality part of Loader. This has a number of benefits: reduced API surface, improves performance by reducing the number of queue switching, enables new features like progress reporting.
  • Remove Scheduler, AsyncScheduler, Loader.Schedulers, DispatchQueueScheduler, OperationQueueScheduler. This whole infrastructure was way too excessive.
  • Make RateLimiter private
  • DataLoader now works with URLRequest, not Request