Repository navigation
fix(SvgImageSource): Keep the load alive when an Image subscribes mid-open - #25166
Merged
Merged
Conversation
…-open Setting UriSource opens the source right away, and the first Image.Subscribe re-opens it, cancelling the first open's token. The cached load was bound to that token, so the re-open reused a load that returned empty: nothing rendered and neither Opened nor OpenFailed fired. The load now has its own cancellation, cancelled only when the source itself changes, like WinUI's DisconnectImageOperation (imagesource.cpp). Regressed in e9801ce, which made Image subscribe to SVG sources. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LP133TsLEXjMo7XFGmakoS
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LP133TsLEXjMo7XFGmakoS
Contributor
|
Claude finished @MartinZikmund's task in 17s —— View job Review of #25166Verdict: ship. No blocking issues, 0 inline findings. What I checked (code review only, nothing built or run):
Notes (non-blocking):
|
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25166/wasm-skia-net9/index.html |
Contributor
|
The build 238747 found UI Test snapshots differences: Details
|
mikernet
added a commit
to Singulink/uno
that referenced
this pull request
Oct 17, 2026
Port of unoplatform#25555 (43b47f5), the 6.8 backport of unoplatform#25166. On Skia, SetSourceAsync(stream) returned Other and drew nothing, and neither Opened nor OpenFailed fired, whether Image.Source was set before or after the call. SetSourceAsync subscribes to the source, which opens it, then calls InvalidateSource, which opens it again and cancels the first open's token, and the cached load was bound to that token. An ImageBrush that subscribes while a UriSource is still loading re-opens it the same way. - The load has its own cancellation, cancelled only when the source itself changes (UnloadImageSourceData), as on master and as in WinUI, where only DisconnectImageOperation aborts a decode. - Tests: When_SVGImageSource_SetSourceAsync_File_Stream, When_SVGImageSource_SetSourceAsync_Twice (Given_Image) and When_SvgImageSource_Assigned_While_Opening (Given_ImageBrush). 6.8 differences: - None: unoplatform#25555 targets servicing/6.8 and cherry-picks clean, also on top of the unoplatform#25124 port. That port leaves an SvgImageSource's data alone while nothing subscribes, so the load this keeps alive is not released under it.
Xiaoy312
pushed a commit
to mikernet/uno
that referenced
this pull request
Nov 6, 2026
On Skia, SetSourceAsync(stream) returned Other and drew nothing, and neither Opened nor OpenFailed fired, whether Image.Source was set before or after the call. SetSourceAsync subscribes to the source, which opens it, then calls InvalidateSource, which opens it again and cancels the first open's token. The load is cached in _currentOpenTask and was bound to that first token, so the second open reused a load whose stream read had been cancelled. An ImageBrush that subscribes to an SvgImageSource whose UriSource is still loading re-opens it the same way. The load now has its own cancellation, cancelled only when the source itself changes (UnloadImageSourceData), as on master since unoplatform#25166 and as in WinUI, where only DisconnectImageOperation aborts a decode.
MartinZikmund
pushed a commit
that referenced
this pull request
Nov 24, 2026
SetSourceAsync subscribes to the source, which opens it, then calls InvalidateSource, which opens it again and cancels the first open's token. #25166 made the SVG load independent of that token, which also fixed stream loading, but only the URI path has a test. These load a file stream, whose read is still in flight when the source is opened again, with Image.Source set before and after the call, and call SetSourceAsync twice on the same source. Each checks the returned status and the drawn color; the first also waits for Opened. The same tests pass on WinUI.
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.
GitHub Issue: n/a (found during Uno 7 QA of a real app)
PR Type
🐞 Bugfix
What is the current behavior? 🤔
An
ImagewhoseSourceis anSvgImageSourcethat is still opening never renders: nothing is drawn and neitherOpenednorOpenFailedfires. Typical trigger:<Image Source="ms-appx:///Assets/logo.svg" />in a page created after startup (seen on Daily Plants' About page with Uno.Sdk 7.0.0-dev.54; renders on Uno 6.7 and on WinUI).Root cause:
UriSourcecallsInvalidateSource(), which opens anSvgImageSourceeven without subscribers.Image.OnSourceChangedsubscribes right away; the firstSubscribe()callsOpen()again, and_opening.Disposable = …cancels the first open's token.SvgImageSource.TryOpenSvgImageDatacached the load with_currentOpenTask ??= LoadSvgImageAsync(ct), bound to that first token. The re-open reuses a load that observes cancellation and returnsImageData.Emptysilently.ms-appxreads in apps, http). When the read completes synchronously (SamplesApp assets) it's masked, which is why the existingWhen_SVGImageSourcerows never caught it.Regressed in e9801ce (
refactor(svg): unify on ISvgRenderer…), which madeImagesubscribe to SVG sources.What is the new behavior? 🚀
The SVG load is owned by the source with its own
CancellationTokenSource, cancelled only inUnloadImageSourceData, i.e. when the source itself changes. A superseded open reuses the in-flight load. A load aborted by a source change returns empty without raisingOpenFailed.WinUI alignment: a decode is aborted only by
DisconnectImageOperation, reached fromOnUriSourceChange/SetSource(dxaml/xcp/core/core/elements/imagesource.cpp), never because anImageattached.Tests
New
Given_Image.When_SVGImageSource_Assigned_While_Openingserves the SVG from a loopbackTcpListenerthat answers after 200 ms, so the first open is deterministically in flight when theImagesubscribes (excluded on WASM: no sockets).Given_Image35/35 pass on Skia desktop (net10.0-desktop, Win32), incl. all existing SVG tests.lastStatus=Success).Note: the final test tweak (stub server tolerating the aborted client + a WaitFor message) was not re-run locally because the machine ran out of memory; CI will cover it.
PR Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01LP133TsLEXjMo7XFGmakoS