Feat: Harden the async image URL pipeline#72
Open
phranck wants to merge 4 commits into
Open
Conversation
- Add the URLImageDataTransport protocol (internal) with a default URLSession-backed implementation that uses async data(for:) instead of a DispatchSemaphore + nonisolated(unsafe) result variable - Add the URLImageCoordinator actor: cache hits skip the transport, concurrent identical URLs share one in-flight task, cancellation routes into the in-flight task, non-2xx responses fail with downloadFailed, and byte limits reject before decoding - Cover cache hit/miss, deduplication, status validation, byte-limit rejection, and cancellation forwarding with a scripted recording transport that observes fetch cancellations
- ImageLoader.loadImage(from urlString:...) is async now; the default falls back to cache lookup and the platform loader delegates to URLImageCoordinator - Delete the DispatchSemaphore + nonisolated(unsafe) BoundedURLImageDataLoader - _ImageCore's mounted task awaits the async URL loader - Update the RecordingRuntimeImageLoader stub and drop the byte-limit test that exercised the removed helper (coverage moved to the URLImageCoordinator suite)
- Add an actor-based SlowURLImageLoader that counts invocations and a URLImageApp fixture; asserts that reading a URL source triggers exactly one loader call, no state mutates during traversal, and no runtime diagnostics fire
…pipeline - Drop overrides for the removed BoundedURLImageDataLoader helper - Add overrides for the new async loadImage(from urlString:...) signature on ImageLoader and PlatformImageLoader - Regenerate the manifest with TUIkitAPICheck against fresh 6.0.3 macOS and Linux snapshots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27.
Summary
URLImageCoordinator(actor): coordinates URL image loads with an injectableURLImageDataTransport. Cache hits skip the transport, concurrent identical URLs share a single in-flight task (deduplication), caller cancellation forwards into the shared task, non-2xx responses fail withdownloadFailed, and byte limits reject before decoding.URLSessionImageTransport: default transport using asyncURLSession.data(for:)— no moreDispatchSemaphoreblocking the concurrency-runtime thread on Linux, no morenonisolated(unsafe)result variable.PlatformImageLoader.loadImage(from urlString:...)isasync throwsnow and delegates entirely to the coordinator.ImageLoaderprotocol updated; the_ImageCoremounted task awaits it. The obsoleteBoundedURLImageDataLoader(semaphore + unsafe state) is deleted._ImageCorelifecycle (verified, unchanged): mounted task is a deferred effect keyed toidentity + source; source changes cancel and restart, the stale-response guard (Task.isCancelled+ explicit source match) already prevents older responses from overwriting newer view phases. Rendering never mutates state from within the traversal window.PlatformImageLoader; caches and in-flight state remain runtime-scoped (existingTUIContextTestsstill cover isolation).Test plan
./scripts/test-linux.shURLImageCoordinatorTests(6 tests): cache hit/miss, dedup, status validation, byte-limit rejection, cancellation forwarding — driven by a scriptedRecordingURLTransportthat observes fetch cancellationsImageAsyncPipelineTests: URL sources commit through the async loader without traversal diagnosticsverify-compatibility-manifest.shpasses against the regenerated manifest