Fix: Derive the image placeholder instead of mutating state in traversal#63
Merged
Conversation
- _ImageCore no longer writes its phase/lastSource state boxes while rendering; the placeholder for a changed source is derived from lastSource != source, so it still shows in the same frame - The mounted loading task is now the only writer: it commits phase first, then lastSource, and skips the commit when cancelled, so a stale load can never pair with a newer source - Since #58 every image frame emitted a body-side-effect RuntimeDiagnostic (unconditional lastSource write); rendering is now diagnostic-free - Add ImageRenderPhaseTests and an injectable TUIContext on FrameHarness
- mountLoadingTask reads lifecycle, loader, cache, timeout, and pixel limit from context.environment instead of taking nine parameters (SwiftLint function_parameter_count)
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.
Summary
_ImageCoreno longer mutates itsphase/lastSourcestate boxes while rendering. The placeholder for a changed source is derived fromlastSource != source, so it still appears in the same frame as the source change — without any state write inside the traversal window.resetLoadingPhaseIfNeededwrotelastSourceBoxon every frame, so every frame containing an image emitted a body-side-effectRuntimeDiagnostic(plus a superfluous invalidation). Rendering an image is now diagnostic-free.ImageRenderPhaseTestscover both contracts end-to-end viaFrameHarness(which gained an injectableTUIContextfor deterministic loaders);mountLoadingTasknow reads its dependencies from the render context (SwiftLintfunction_parameter_count).Refs #27 — delivers the "Rendering does not mutate image phase merely by reading the same source" acceptance criterion; the remaining transport/validation/dedup work stays in #27.
Test plan
ImageRenderPhaseTests: RED verified against the old behavior (diagnostic on every frame), GREEN after the fix./scripts/test-linux.sh: full warning-fatal gate green on macOS and Linux (1317 tests, 1 expected known issue for [P0-09] Preserve subtree liveness across EquatableView cache hits #14)