Visitar URL original
fix(imaging): Keep a shared BitmapImage download alive when one requester cancels, drop failed loads from the cache (backport #25101) (backport #25915) by mergify[bot] · Pull Request #25916 · unoplatform/uno · GitHub
Skip to content

fix(imaging): Keep a shared BitmapImage download alive when one requester cancels, drop failed loads from the cache (backport #25101) (backport #25915) - #25916

Merged
agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25915
Nov 2, 2026
Merged

agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25915

Conversation

@mergify

@mergify mergify Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: Related to #25096

PR Type:

🐞 Bugfix

What changed? 🚀

Manual backport of #25101 to servicing/6.8, for 6.7 SR3. It builds on #25911 (the IgnoreImageCache fix, already on this branch).

  • Before: on Skia, BitmapImages that open the same URI share one cached download. When one of them cancelled its open (for example a recycled ListView container), the shared download was cancelled too, and the other images stayed blank. A failed download also stayed in the cache, so later images for the same URI failed as well.
  • After: a shared download keeps running when one image cancels, and a failed download is dropped from the cache, so the next request downloads again.
  • Why not Mergify: on 6.x the code is in BitmapImage.skia.cs, LRUCache is under Uno.UWP/Helpers, and the test is under Tests/Windows_UI_Xaml_Media_Imaging. The 4 commits are master's with only those paths changed; the changed lines are the same.

PR Checklist ✅

Local validation (Skia Desktop, Windows)

Runtime tests on this branch, filtered to Tests.Windows_UI_Xaml_Media_Imaging and Given_Image: 55 of 57 passed, including the 4 Given_BitmapImage tests (3 of them new in this PR).

  • Given_WriteableBitmap.When_WriteableBitmap_Assigned_With_Data_Present failed on its pixel check, the same as on this branch without the change. It doesn't use BitmapImage.
  • Given_RenderTargetBitmap.When_Render_Border_GetPixelsAsync was inconclusive: it needs 100% display scaling.

🤖 Generated with Claude Code


This is an automatic backport of pull request #25915 done by [Mergify](https://mergify.com).

mikernet and others added 4 commits November 2, 2026 04:12
…ster cancels

The in-flight load cached by URI and decode size is awaited by every BitmapImage opening the same source, but it ran on the first requester's cancellation token. When that requester re-opened (a recycled ListView container binding a new UriSource), the shared task completed with a cancellation error, so every other BitmapImage for that URI raised ImageFailed and stayed blank, and nothing retried.

The shared load now runs on no requester's token, as WinUI's ImageCache does when a request is released, and each requester waits under its own token so a cancelled open neither fails nor applies a stale result. Uncached loads (IgnoreImageCache or cache disabled) still cancel with their sole requester.

Fixes #25096

Backport note: 6.x paths (BitmapImage.skia.cs, Uno.UWP/Helpers/LRUCache.cs,
Tests/Windows_UI_Xaml_Media_Imaging); the changed lines are the same as on master.

(cherry picked from commit a06c0a8)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9804660)
…led requester

Uses a loopback server that holds the image bytes until released, so the test cancels the first requester while the download is deterministically in flight.

Backport note: 6.x paths (BitmapImage.skia.cs, Uno.UWP/Helpers/LRUCache.cs,
Tests/Windows_UI_Xaml_Media_Imaging); the changed lines are the same as on master.

(cherry picked from commit cedc6b0)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d6064f7)
A cached load that completes with an error stayed in the LRU until eviction, so one transient failure (offline moment, 503, DNS hiccup) kept failing every later BitmapImage for that URI with no retry. WinUI's provider store does not own its ImageCache: a failed one is dropped as soon as its requesters release it and the next request downloads again. The LRU owns its entries, so a continuation on the shared task now removes the entry when the load fails, guarded so it only removes the entry while it still holds that very task, as ImageProvider::RemoveImageCache does.

Fixes #25096

Backport note: 6.x paths (BitmapImage.skia.cs, Uno.UWP/Helpers/LRUCache.cs,
Tests/Windows_UI_Xaml_Media_Imaging); the changed lines are the same as on master.

(cherry picked from commit b77bdb4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 998caa6)
…r requesters

The gated server can answer the next request with an HTTP 500, so a BitmapImage opened after one failed must download again and open.

Backport note: 6.x paths (BitmapImage.skia.cs, Uno.UWP/Helpers/LRUCache.cs,
Tests/Windows_UI_Xaml_Media_Imaging); the changed lines are the same as on master.

(cherry picked from commit 5254005)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5dc1d00)
@agneszitte
agneszitte merged commit 5ea9096 into release/stable/6.7 Nov 2, 2026
13 of 16 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-25915 branch November 2, 2026 04:14
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants