Skip to content

2026.9.1

Latest

Choose a tag to compare

@uaremad uaremad released this 31 Aug 19:08
908f996

AsyncCachedImage 2026.9.1

Overview

This release fixes a URL-change rendering issue in AsyncCachedImage. The component now correctly reloads when SwiftUI reuses the same view instance for a different image URL after a successful load.

The previous image remains visible while the new image loads, preserving the flicker-free behavior, but stale async results are prevented from overwriting newer state.


Bug Fixes

Reload When URL Changes After Successful Load

Fixed: AsyncCachedImage could keep showing an old image when the url changed on an existing SwiftUI view instance.

This happened because any .success phase was treated as already loaded, regardless of which URL produced that image.

Previous Behavior:

  • A successful image load could block future loads
  • Changing url did not always trigger a new cache or network lookup
  • Reused SwiftUI views could keep displaying an image from an older URL
  • Slow async results could theoretically overwrite newer state

New Behavior:

  • Successful loads are now associated with the URL that produced them
  • Loading is skipped only when the current success belongs to the requested URL
  • URL changes trigger a fresh memory, disk, or network lookup
  • The old image remains visible while the new image loads
  • Stale disk, network, and revalidation results are discarded safely

Technical Changes

URL-Aware Load Policy

The load decision has been moved into a focused internal policy:

  • Tracks whether the current .success phase belongs to the requested URL
  • Allows duplicate loads to be skipped only for the same URL
  • Ensures URL changes after success trigger a new load
  • Keeps retry behavior intact after failures

Stale Request Protection

Async loading and revalidation now compare against the live active URL before mutating state.

This prevents outdated async work from updating phase, loadedURL, or cache metadata after SwiftUI has already re-rendered the view for another URL.

Revalidation Flow

Foreground revalidation no longer runs through an unstructured onAppear task. It is now routed through URL-scoped SwiftUI tasks, making cancellation and URL changes easier to reason about.


Migration Guide

No Breaking Changes

This release does not change the public API. Existing AsyncCachedImage usage continues to work without modification.


Testing

This release adds regression coverage for URL changes after a successful load.

Validated with:

make build-ios
swift test