Skip to content

Restore UriImageSource stream caching - #37690

Draft
jfversluis wants to merge 2 commits into
mainfrom
jfversluis-restore-uri-image-caching
Draft

jfversluis wants to merge 2 commits into
mainfrom
jfversluis-restore-uri-image-caching

Conversation

@jfversluis

@jfversluis jfversluis commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Description

Restores disk caching for UriImageSource stream consumers. The previous IsolatedStorage implementation was disabled after GetUserStoreForApplication() failed on Android, then removed while leaving the download-only path and TODO behind. This replaces it with a shared file-system cache under FileSystem.CacheDirectory.

The cache now:

  • honors CachingEnabled, CacheValidity, and HTTP Cache-Control: no-store
  • uses SHA-256 URI-derived keys and coalesces concurrent requests for the same URI
  • streams network responses directly to temporary files instead of buffering complete images in memory
  • limits persistent storage to 100 MiB, individual entries to 25 MiB, and aggregate in-flight temporary storage to 25 MiB
  • trims least-recently-used entries, removes expired entries on access, and cleans abandoned temporary files at process startup
  • atomically promotes completed entries and preserves the first successful download if publication fails
  • propagates cancellation through response-body reads and keeps HTTP response/client ownership tied to returned streams
  • preserves seekable stream requirements across modern and compatibility Windows image services

The iOS image service shares the bounded cache for custom URI stream sources, honors CacheValidity, avoids duplicate platform cache entries for the built-in Controls UriImageSource, and keeps network reads off the captured UI context.

Android continues to use Glide and Tizen continues to use its platform URL loader. Their existing platform caches are unchanged, and exact CacheValidity enforcement on those native paths remains outside this focused stream-cache restoration.

Fixes #9138

Validation

  • 5,735 Controls Core tests passed, 26 skipped, including 23 focused URI cache tests
  • loopback HTTP coverage for cross-instance hits, disabled caching, expiry, slow streaming, no-store, and cancellation before and after response headers
  • filesystem/concurrency coverage for request coalescing, size bounds, LRU trimming, abandoned temporary cleanup, atomic refresh with open readers, cache publication failure, and zero validity
  • Controls builds passed for netstandard2.0, netstandard2.1, net10.0-android36.0, net10.0-ios26.0, and net10.0-maccatalyst26.0
  • the earlier draft revision passed the full MAUI device-test pipeline across Android, iOS, Mac Catalyst, and Windows
  • local Windows compilation reaches Windows-only XamlCompiler.exe/MakePri.exe, which cannot execute on macOS; the updated Windows paths are left to normal PR CI

Multiple adversarial review rounds covered storage exhaustion, memory amplification, HTTP and stream ownership, cancellation, concurrency, cache publication, and modern/compatibility platform behavior. The final round reported no remaining major or moderate findings.

Restore disk caching for stream-based URI image consumers, coalesce concurrent downloads, honor expiration, and avoid duplicate iOS caching. Add loopback HTTP and filesystem coverage for cache hits, expiry, cancellation, and failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@jfversluis

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@jfversluis

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

Stream cache misses directly to bounded temporary files, enforce persistent and per-entry limits, clean abandoned files, honor no-store responses, and preserve cancellation and platform stream requirements.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e5a7c9d1-095b-4f5f-8de6-ff9133d90f68
@jfversluis

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 22, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 7 findings

See inline comments for details.

{
try
{
if (!IsCacheValid(cachePath, cacheValidity))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness — TryOpenCachedFile deletes the cached file as soon as it is judged stale (if (!IsCacheValid(...)) { if (File.Exists(cachePath)) File.Delete(cachePath); return null; }) and only then does the caller attempt the network download. Concrete scenario: a device is offline and the entry's CacheValidity (default 1 day) has just elapsed. The still-readable bytes are destroyed first, download(...) fails or returns null, and the image renders as nothing — whereas the pre-PR iOS path (IsImageCached(pathToImageCache) = File.Exists) served the stale file and the image kept rendering. Deleting only after a successful download, or falling back to the stale entry when download yields null/throws, preserves the offline behavior while still honoring CacheValidity when the network is reachable.

string cacheDirectory,
long maxCacheSize,
string? protectedPath,
DateTime utcNow,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness — The DateTime utcNow parameter is never read anywhere in TrimCache's body; both call sites pass DateTime.UtcNow and it is silently discarded. This is not just a dead parameter — it signals that eviction is purely size/LRU based: an entry that is past its CacheValidity is never removed by trimming and stays on disk indefinitely until the 100 MB MaxCacheSize cap happens to evict it by last-access order. For an app with a small working set of images, expired blobs accumulate permanently in FileSystem.CacheDirectory. Either use utcNow to drop expired entries during the trim pass, or remove the parameter so the size-only policy is explicit.

reservation.Dispose();
reservation = null;

var completedStream = OpenCacheFile(temporaryPath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness — The completed temp file is opened for reading (var completedStream = OpenCacheFile(temporaryPath);) before it is published via File.Replace(temporaryPath, cachePath, null) / File.Move on the following lines. File.Move tolerates the outstanding handle because OpenCacheFile passes FileShare.ReadWrite | FileShare.Delete, but Win32 ReplaceFile (which backs File.Replace) is not covered by that share mode in the same way, so on Windows the File.Exists(cachePath) branch — i.e. every refresh of an already-cached URI — can fail with a sharing violation. The catch (IOException ...) swallows it and returns a TemporaryFileStream, so the failure is invisible: the image still loads but the refreshed bytes are never written to cachePath, and the URI re-downloads on every subsequent request forever. Publishing first (move/replace) and opening cachePath afterwards removes the ambiguity on all platforms.

HttpResponseMessage response = null;
try
{
response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Cross-Platform Behavioral Consistency — Switching to HttpCompletionOption.ResponseHeadersRead changes the contract of the stream returned by StreamWrapper.GetStreamAsync on every platform: it was a fully-buffered, seekable stream (default HttpCompletionOption.ResponseContentRead reads the body before GetAsync completes) and is now an unbuffered, non-seekable live network stream. The PR adapts only the Windows consumers (EnsureSeekableAsync added to UriImageSourceService.Windows.cs, StreamImageSourceService.Windows.cs, and the two compatibility handlers). The Android consumer src/Core/src/ImageSources/StreamImageSourceService/StreamImageSourceService.Android.cs (lines 25 and 62) takes the same IStreamImageSource.GetStreamAsync result and was not audited or adapted, and neither was Tizen. Any consumer that relied on CanSeek, Length, or on re-reading from position 0 now silently changes behavior on those platforms. Please state which non-Windows consumers were checked, or add the equivalent seekable-stream guarantee at the source.

{
internal static class ImageSourceServiceExtensions
{
public static async Task<Stream> EnsureSeekableAsync(this Stream stream, CancellationToken cancellationToken)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Performance-Critical Path — EnsureSeekableAsync copies the entire response into an unbounded MemoryStream whenever !stream.CanSeek, which after the ResponseHeadersRead change is now the normal case for every remote image on Windows. This bypasses the size bounds the PR carefully establishes elsewhere (MaxCacheEntrySize = 25 MB, MaxTemporaryCacheSize = 25 MB): a large or malformed remote image is buffered in full into managed memory with no cap and no ExpectedLength pre-check, even though IImageSourceCacheStream.ExpectedLength is already available on the StreamWrapper being passed in. Consider consulting ExpectedLength / applying a ceiling before buffering.


static NSData GetImageData(Stream stream, Uri uri)
{
var imageData = NSData.FromStream(stream);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Async and Threading Safety / iOS Platform — NSData.FromStream(stream) reads the stream with the synchronous Stream.Read loop. Before this PR that was harmless because HttpClient had already buffered the whole body, so the reads were pure memory copies. With HttpCompletionOption.ResponseHeadersRead (StreamWrapper.cs:147), this is now blocking network I/O: GetImageData runs on a thread-pool thread (reached after ConfigureAwait(false) awaits) and that thread stays blocked for the full download duration. Concrete scenario: a page with N remote UriImageSource images that bypass the disk cache (CachingEnabled=false, Cache-Control: no-store, or an entry over MaxCacheEntrySize) blocks N pool threads simultaneously on slow connections, starving the pool. Buffering asynchronously (e.g. CopyToAsync into an NSMutableData-backed or pooled buffer) before handing bytes to NSData avoids the sync-over-network read.

return File.Exists(path);
}

internal bool IsImageCached(string path, TimeSpan cacheValidity)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — internal bool IsImageCached(string path, TimeSpan cacheValidity) is added here but is never called by any production path: the caching decision now lives entirely in UriImageSourceCache.IsCacheValid (UriImageSourceCache.cs:194), and DownloadAndCacheImageAsync no longer consults IsImageCached at all. The only consumer is the new device test CachedImageHonorsCacheValidity (UriImageSourceServiceTests.iOS.cs), which therefore asserts against a dead helper and provides no coverage of the shipped validity logic — the duplicated TimeSpan.Zero / TimeSpan.MaxValue / LastWriteTimeUtc rules in IsCacheValid could regress with this test still green. This matters more than usual because the gate is INCONCLUSIVE (tests could not be built/run), so this is the PR's only iOS-side validity evidence. Please point the test at UriImageSourceCache (it is already internal and reachable) and drop the unused overload, and add a case covering the expired-entry-plus-failed-download path flagged at UriImageSourceCache.cs:208.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 22, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 30, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 9 findings

See inline comments for details.

if (!IsCacheValid(cachePath, cacheValidity))
{
if (File.Exists(cachePath))
File.Delete(cachePath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness — The expired cache entry is deleted before the refresh download is attempted. TryOpenCachedFile runs File.Delete(cachePath) on any entry that fails IsCacheValid, then control falls through to download(cancellationToken). Concrete scenario: an app with CachingEnabled=true, CacheValidity=1 day is launched offline on day 2. The still-readable cached bytes are destroyed, the download throws/returns null, and GetStreamAsync returns null — the image that previously rendered from cache now renders nothing, and the bytes are gone for every subsequent offline launch. The pre-PR behavior (no disk cache at all) at least degraded identically each time; this change makes a previously-working offline render fail permanently. Delete the stale file only after the replacement has been successfully written (or fall back to the stale entry when the refresh fails).

throw;
}

return await download(cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness — On a cache-write failure the method issues a second full network download. The catch (IOException) / catch (UnauthorizedAccessException) blocks above dispose downloaded when cacheFileCreated is true and then fall through to this return await download(cancellationToken). Concrete scenario: device storage is full, so File.Create/WriteAsync throws for every image on the page — each image is fetched twice over the network, doubling data usage and latency, and the second attempt has no protection against failing the same way. The already-downloaded bytes are discarded rather than being streamed straight to the caller.

{
lock (s_temporaryCacheSync)
{
if (s_temporaryCacheSize + bytes > MaxTemporaryCacheSize)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Async and Threading Safety — s_temporaryCacheSize is a process-wide counter that is only decremented by TemporaryCacheReservation.Dispose(). On the overflow path the reservation's lifetime is bound to the returned TemporaryAndNetworkStream, so it is only released if the consumer disposes that stream. Concrete scenario: a platform image handler abandons the stream (cancelled load, thrown decode, handler disconnected mid-load) for enough oversized images to accumulate 25 MB of un-disposed reservations — TryReserve then returns false for every subsequent download for the remaining process lifetime, so disk caching is silently and permanently disabled app-wide with no recovery path and no log. A reservation tied to a caller-owned stream needs either a finalizer-backed release or a bound that cannot be exhausted by leaked consumers.

string cacheDirectory,
long maxCacheSize,
string? protectedPath,
DateTime utcNow,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[minor] Complexity Reduction — The DateTime utcNow parameter is never read inside TrimCache; IsCacheValid reads DateTime.UtcNow directly instead. Both call sites pass DateTime.UtcNow, so the parameter only creates the false impression that trimming is time/expiry aware. Related consequence: trimming is purely size-and-LRU based, so entries that are already past CacheValidity still count toward MaxCacheSize and are only removed when that exact URI is requested again — a cache holding 100 MB of expired entries will evict valid entries to make room. Either use the parameter to drop expired entries during the trim, or remove it.

HttpResponseMessage response = null;
try
{
response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Cross-Platform Behavioral Consistency — Switching to HttpCompletionOption.ResponseHeadersRead changes the observable contract of the stream returned by IStreamImageSource.GetStreamAsync. Previously the response was fully buffered, so _wrapped was a seekable MemoryStream and StreamWrapper.CanSeek was true, Length returned the byte count, and Seek/Position worked. It is now a live network stream, so CanSeek is false and Length/Position/Seek (lines 55–120, which forward unchanged to _wrapped) throw NotSupportedException. Only the four Windows consumers were adapted via EnsureSeekableAsync; any other consumer that rewinds or reads Length — custom IImageSourceService implementations, compatibility renderers, and third-party handlers that call GetStreamAsync on a UriImageSource — now throws where it previously worked. This is a silent breaking change to a stream handed across an assembly/extensibility boundary; it needs either an explicit seekable guarantee (buffer at the StreamWrapper level) or a documented contract change plus cross-platform regression coverage.

return new StreamWrapper(
stream,
owner,
canCache: owner.Response.Headers.CacheControl?.NoStore != true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness — Cacheability is derived solely from CacheControl?.NoStore != true. no-cache, max-age=0, s-maxage=0, must-revalidate, private, Pragma: no-cache, and a past Expires header are all ignored, so a response the origin explicitly marked as non-reusable is written to the on-disk cache and then served for the full CacheValidity window without revalidation. Concrete scenario: an endpoint that returns a rotating/session-scoped image with Cache-Control: no-cache (very common — no-cache is far more widely emitted than no-store) is frozen on disk for the app's configured validity, so users keep seeing a stale image. Also note expectedLength is taken from Content-Length, which is absent for chunked responses; those bypass the maxCacheEntrySize pre-check entirely and rely only on the streaming overflow path.


static NSData GetImageData(Stream stream, Uri uri)
{
var imageData = NSData.FromStream(stream);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Async and Threading Safety — NSData.FromStream is a synchronous, blocking read, and after this PR the stream it receives can be a live network stream rather than fully buffered bytes. Trace: DownloadAndCacheImageAsync → (for UriImageSource, which now implements IStreamImageSourceWithCache) DownloadImageAsync → UriImageSource.GetStreamAsync → UriImageSourceCache.GetStreamAsync, which returns the raw StreamWrapper on the CanCache: false and ExpectedLength > maxCacheEntrySize paths, and a TemporaryAndNetworkStream (whose tail is the socket) on the overflow path. Concrete scenario: a Cache-Control: no-store or >25 MB image on a slow connection now blocks a thread-pool thread inside NSData.FromStream for the whole transfer instead of only for a memory copy; several such images concurrently starve the pool. Before this PR the buffering happened inside client.GetAsync, which was awaited. Read the stream asynchronously into an NSMutableData/buffer before constructing the NSData.

return File.Exists(path);
}

internal bool IsImageCached(string path, TimeSpan cacheValidity)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Regression Prevention and Test Coverage — This new IsImageCached(string, TimeSpan) overload has no production caller. The iOS validity logic it duplicates now lives in UriImageSourceCache.IsCacheValid, and DownloadAndCacheImageAsync (lines 47–71) never calls this overload — nor does anything else in src/. Its only references are in UriImageSourceServiceTests.iOS.cs. Adding internal surface that exists solely to be asserted on gives the appearance of validity coverage without exercising the code that actually decides cache validity; the legacy GetCachedFileName/CacheImage/GetCachedImage helpers around it are likewise now dead for the URI path. Either route the production path through this helper or drop it and test UriImageSourceCache directly.


try
{
Assert.True(service.IsImageCached(path, TimeSpan.FromMinutes(1)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Regression Prevention and Test Coverage — This is the only new device test for the PR's headline behavior (iOS honoring CacheValidity), but it asserts against service.IsImageCached(path, TimeSpan) — a helper with zero production callers (see UriImageSourceService.iOS.cs:119). It will stay green even if UriImageSourceCache expiry, eviction, the File.Replace/File.Move publication step, or the IStreamImageSourceWithCache short-circuit in DownloadAndCacheImageAsync are completely broken. The issue being fixed (#9138) reports that iOS does not honor validity, so per the repo's regression-test requirement this needs a test that drives DownloadAndCacheImageAsync/UriImageSourceCache.GetStreamAsync across an expiry boundary and asserts a re-download actually occurred, plus coverage for the no-store and oversized-entry paths which are currently untested on device.

@MauiBot MauiBot removed s/agent-fix-win AI found a better alternative fix than the PR s/agent-review-in-progress AI review is currently running for this PR labels Aug 30, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check the ai's suggestions?

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

kubaflo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@jfversluis, is this draft PR ready for review? If it still needs work, please leave it as a draft; otherwise, please mark it ready for review.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15596738 is running for ios.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15597037 is running for ios.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
kubaflo added a commit that referenced this pull request Oct 13, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Add `/review gate` as an explicit existing-test-only mode without
replacing or shortening the existing hosted `/review` process. Bare
`/review`, its platform/branch options, and dispatches that omit the new
flag continue to select the full review. `/review tests` and `/review
performance` remain independent.

The gate retains the existing selected unit, XAML, device, and UI
verifier, including failure-only verification for test-only changes,
bounded native selection, retry handling, and skipped/inconclusive
outcomes. It does not generate missing tests or run expert code review,
Try-Fix, deep-category UI sweeps, or Copilot inference. These exclusions
apply only to gate mode; hosted `/review` and local full-review tools
retain their existing phases.

Publish a commit-pinned, bounded report with a closed **Gate analysis**
section. The original expandable layout from #38807 is refined to match
[the user-selected test-failure-analysis
comment](#37572 (comment)):
an author/commit quote, flat-square result/platform/commit badges, and
readable result tables grouped by test type. At the user's request, omit
the Scope badge/text, Follow-up accordion, and report/artifact-link
footer. Only recognized diagnostic fields are rendered; raw
execution-log excerpts remain escaped in their own collapsed section
rather than displaying a raw Markdown document. Posting runs on a fresh
agent and only maintains gate signals and publisher-owned gate comments;
it does not approve PRs or edit their titles/descriptions. The trigger
and scheduled recovery recognize both commands and preserve the selected
mode after permission and source-comment revalidation. Previously
removed existing full-review coverage is restored unchanged; no new
pipeline/configuration tests are added.

Live validation exposed two selection defects: a closed nested Picker
helper was mistaken for its test fixture, and a nested XAML `Test`
fixture became an assembly-wide filter. Resolve containing class scopes
using the existing C# declaration scanner, and group nested XAML
fixtures by their page. Build errors and no-match results remain visibly
unverified in both detailed evidence and the console summary. Keep the
verifier's existing passing policy, but make the publication explicit
that unmatched/inconclusive groups are not successful execution
evidence.

A publication canary exposed an unnecessary repository-label metadata
PATCH returning HTTP 404. The gate now assigns the existing gate labels
without editing repository-wide descriptions/colors. Required assignment
failures explicitly fail publication instead of being ignored. The final
live publication completed without that warning.

**Additive routing at production source
`3e96214dacd9c65b3e99b0f23801e197722d0fc3`:**

| Request | Selected pipeline |
| --- | --- |
| `/review` or normal/default dispatch | Existing full review, Deep UI,
final AI Summary, cleanup, and telemetry |
| `/review gate` or `gate_only=true` | Setup/Gate, fresh gate-only
publication, and cleanup |
| `/review tests` / `/review performance` | Their unchanged independent
workflows |

`eng/pipelines/ci-copilot.yml` keeps the original full stages inline and
defaults `GateOnly` to **false**. Its explicit true branch selects
`pr-review-gate.yml` at compile time, so gate runs contain no
full-review/inference, Deep UI, or token-aggregation jobs. The parent
passes the shared 150-minute Gate task limit as a typed template
parameter; an actual Azure compiler preview exposed that the extracted
stage template cannot read the parent's static timeout directly. No new
Azure definition, secret, permission, or OIDC trust is required.

**Current validation:**

- `actionlint .github/workflows/review-trigger.yml
.github/workflows/review-trigger-recovery.yml` - passed. Both Azure YAML
files parse, all four changed production PowerShell scripts and 48
compile-time-expanded embedded PowerShell blocks parse, and `git diff
--check` passes.
- Azure Runs API `previewRun=true` on definition 27723 with the
production branch and exact SHA above - **nine successful compiler
previews**: omitted mode, explicit false on
Android/iOS/Catalyst/Windows, and explicit true on all four platforms.
Omitted mode expands identically to false. Full mode retains all five
original stages; gate mode includes only `Gate`, `PostGate`, and
`CleanupReviewLock`, with a 150-minute credential-free Gate task.
- `Invoke-Pester -Path @('.github/scripts/ReviewTrigger.Tests.ps1',
'.github/scripts/Recover-MissedReviewCommands.Tests.ps1',
'.github/scripts/Review-PR.Tests.ps1',
'.github/scripts/CopilotPipeline.Tests.ps1',
'.github/scripts/shared/Prepare-UITestFailureAnalysis.Tests.ps1',
'.github/scripts/Post-AISummaryComment.Tests.ps1') -Output Minimal
-PassThru` - **246 passed, two unchanged model-pin assertions failed**
against the independent, untouched `Review-Tests.ps1`. The restored
existing suites and implicated product files match the original/current
main versions; these unrelated assertions are not changed to manufacture
a green result.
- [Remote additive canary
15652574](https://devdiv.visualstudio.com/0bdbc590-a062-4c3f-b0f6-9383f67865ee/_build/results?buildId=15652574),
queued by [the existing trusted-main
dispatcher](https://github.com/dotnet/maui/actions/runs/38237622825),
**succeeded** on this draft PR. Only Gate, fresh PostGate, and Cleanup
jobs ran; all three succeeded. The no-MAUI-tests control truthfully
reported **SKIPPED**, not native test execution. Its 7,062-byte GateLogs
artifact contains regular allowlisted diagnostics. The new [MauiBot
report](#39189 (comment))
has three badges and a closed Gate analysis with no Scope, Follow-up, or
footer; its reviewed head and protected baseline are pinned. Actual
GitHub state confirms no gate pass/fail or full-review signals and a
released lock. Distinct hosted worker IDs confirm fresh-agent
publication. Direct queue access was denied; the already-authorized
dispatcher was used without changing credentials or trust.
- This pre-merge canary uses isolated source
`783a98445b269b3e9e30fef82e98d898ada3a74f` on
`kubaflo-gate-only-additive-canary-3e96214`. It differs from production
only in the declared `GateOnly` default, temporarily true because the
old main dispatcher cannot pass the new input. Its actual Azure-expanded
stages are identical to production with explicit true. The production PR
remains at the SHA above with default **false**.
- `Get-CIStatus.ps1 -PRNumber 39189 -Repository dotnet/maui -MaxJobs 100
-MaxFailureLines 20 -NoCache` - completed and refreshed after the
canary; [normal maui-pr build
1631878](https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1631878)
is still in progress for raw source
`3e96214dacd9c65b3e99b0f23801e197722d0fc3` and merge source
`74b9a40864ccb43a4079c8bb5d50fd20d53ea0ef`. The latest snapshot has six
succeeded jobs, 20 pending/running, and no failures. Pending CI is not
passing CI.

<details>
<summary>Earlier source-specific Gate execution, ten-PR canaries, and
compact-comment validation</summary>

The evidence below is preserved at its original execution/presentation
sources. It does not claim that the ten earlier canaries ran at the
newest additive source.

**End-to-end execution validation at source
`8e639d714ae303b62b537596cf488a476393bdc1`:**

- Final publisher PowerShell parsing and `git diff --cached --check`
passed. Earlier changed PowerShell/embedded Azure Bash and PowerShell
syntax checks, YAML parsing, and `actionlint
.github/workflows/review-trigger.yml
.github/workflows/review-trigger-recovery.yml` passed; the follow-ups do
not alter those YAML files.
- `Invoke-Pester -Path
@('.github/scripts/shared/Update-AgentLabels.Tests.ps1',
'.github/scripts/shared/Detect-TestsInDiff.Tests.ps1',
'.github/skills/verify-tests-fail-without-fix/scripts/Verify-TestsFail.Tests.ps1')
-Output Minimal -PassThru` — 176 passed, zero failed. The actual console
summary renderer was exercised with build-error, unmatched-filter, and
environment-error records; none appeared as expected assertion failures.
The final live log also correctly displays `BUILD ERR` rather than a
successful runtime failure.
- Azure Runs API previews succeeded for Android, iOS, Catalyst, and
Windows, with only Gate, PostGate, and lock cleanup jobs. The Android
`RunGate` task expands to 150 minutes. Those YAML configurations are
unchanged by the publisher follow-ups.
- The full detector against the exact #39175 test files selects only
`UnitTest:PickerTests` and `XamlUnitTest:Maui30644`, merging the XAML
page and code-behind rather than selecting a closed helper or broad
`Test` filter.
- The [hosted PowerShell suite at that
source](https://github.com/dotnet/maui/actions/runs/37511816441) matches
the existing workflow-equivalent selection: 2,456 passed and three
unchanged model-policy assertions failed against the independent
`/review tests` implementation/workflow files. Those unrelated model
pins are not changed here. The retained local full-review publisher's 75
existing regressions pass.
- [Skill validation at that
source](https://github.com/dotnet/maui/actions/runs/37511811901): static
validation passed, but the evaluation artifact exits 1 with 12 protocol
and 18 capability session-construction errors (`Session filesystem path
escapes root`), zero evaluation turns, and zero tokens. The unchanged
hermeticity harness separately fails while materializing missing
sparse-checkout blobs (`Could not reset index file to revision 'HEAD'`).
A green execution job is not a passing skill evaluation.
- [First live Picker/XAML canary on
#39175](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15583760):
`Maui30644` reproduced the issue and passed all three cases with the
fix, but the incorrect Picker filter matched no tests. The corrections
above address that selection. #39175 merged before publication; the
publisher correctly refused the closed target and cleanup released its
lock.
- [Second Android canary on
#37572](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15584958)
completed the Gate, fresh publication, and cleanup, but exposed the
repository-label metadata warning corrected above. Its owned report was
superseded by the final canary.
- [Final Android canary on
#37572](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15585863),
dispatched through [trusted
`main`](https://github.com/dotnet/maui/actions/runs/37511805027),
**succeeded at the exact source SHA above**. The selected
`AnimationTests` baseline cannot compile without the fix's internal
`HasTweener` API; all seven cases pass with the fix. This exercises the
verifier's existing compile-coupled mode, not runtime FAIL-to-PASS
reproduction.
- The final fresh agent published [the gate
report](#37572 (comment)),
applied the appropriate gate signal without repository-label metadata
edits, and minimized the previous owned report as outdated. Actual
GitHub state confirmed the old report minimized, the new report visible,
the tested head unchanged, and the in-progress lock absent. Cleanup
succeeded. No new full-review tracking/outcome labels or PR metadata
edits are claimed.

**Comment-presentation follow-up at source
`4d85e1f9307a83aba11c4603603876de8dcb121c`:**

- Publisher PowerShell parsing and `git diff --cached --check` passed.
The existing targeted label, detector, verifier, and local full-review
publisher suites passed: **251 tests, zero failures**. No new
pipeline/configuration tests were added.
- `Post-PRGate.ps1 -DryRun` used the exact final-canary diagnostic
transcript and immutable commit/run identities. The actual GitHub
Markdown API rendered four badges, a real before/after results table,
closed Gate analysis and Follow-up sections, and separately escaped
execution logs. The existing failure-only report writer was also
exercised with all four test types; skipped/no-report and merge-blocked
previews do not claim execution or a with-fix result.
- At the user's request, a separately guarded maintainer edit
reformatted **the same existing MauiBot comment**, rather than running
the publisher under a different identity or posting a duplicate. The
live comment's `body_html` read-back confirms the new rendering. MauiBot
attribution, the original verdict/run, both tested commits, the PR head,
and every label are unchanged. This is a presentation-only edit of
existing evidence, **not a new Azure verification run**.

**Requested ten-PR canary batch — all ten outcomes verified:**

All ten original runs were dispatched from trusted `main` with the
custom `pipeline_ref` at source
`4d85e1f9307a83aba11c4603603876de8dcb121c`. Original identities remain
preserved separately from corrective attempts. Corrective
unit-selection/publication runs used
`78bb5d3a3bc6da91357b5b116542d77bcc283449`; final Windows helper
validation used `d4397eaa8b855209c963ea8aad201508c3d45c05`; the
additional Windows bootstrap control used source
`ecd602ef48662a2a59f083d9db8fc5bdfb83fd45`. The batch is not represented
as ten runs at the newest source.

| PR | Platform | Verified outcome | Actual evidence |
| --- | --- | --- | --- |
|
[#37319](#37319 (comment))
| Android | FAILED |
[15596739](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15596739):
with-fix unit execution has 53 passes and two genuine stroke-transition
assertion failures. The independent UI case fails without the fix and
passes with it, but does not conceal the unit failures. Unit baseline is
compile-coupled to the new API. |
|
[#38441](#38441 (comment))
| Catalyst | PASSED |
[15596747](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15596747):
selected CollectionView height-update device case fails without the fix
and passes with it. |
|
[#38625](#38625 (comment))
| Android | PASSED |
[15596742](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15596742):
64 selected with-fix unit/SourceGen/XAML cases pass across five groups;
baseline compilation is coupled to the new API. |
|
[#39013](#39013 (comment))
| Android | PASSED |
[15596744](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15596744):
the selected CurrentItem-after-removal UI case runs and fails without
the fix, then runs and passes with it. |
|
[#38883](#38883 (comment))
| Catalyst, corrective host | FAILED |
[15597032](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597032):
corrected `SkiaSharpSvgToolsTests` selects 16 cases, including both
PR-added SVG tests. All pass without the fix, on confirmation, and with
it. The selected unit tests do not reproduce this packaging change; this
is not a with-fix test failure. |
|
[#39213](#39213 (comment))
| Android; Windows control | SKIPPED | Original corrective Android
control
[15597033](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597033)
and Windows bootstrap control
[15597596](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597596)
both select no tests. No successful test execution or passing signal
claimed. |
|
[#37690](#37690 (comment))
| iOS, corrective run | INCONCLUSIVE |
[15597037](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597037):
all 23 selected unit cases pass with the fix; baseline cannot compile
against the new cache API. Scoped device execution produces no fresh
XHarness XML, so overall verification stays inconclusive. |
|
[#38843](#38843 (comment))
| iOS, corrective run | INCONCLUSIVE |
[15597038](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597038):
test-only ScrollView verification produces no fresh device result. No
with-fix execution is claimed. |
|
[#39185](#39185 (comment))
| Android | FAILED |
[15596745](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15596745):
selected `BindingPath_Parsed` passes without the fix, both
confirmations, and with the fix. Fresh method-scoped XML contains one
passing result; a different failure in the broader class cannot count as
reproduction of this selected test. Actual inflight baseline is
`262d95940f646b601093b36db4e27c691670d753`. |
|
[#39179](#39179 (comment))
| Windows, final helper run | PASSED, failure-only |
[15597455](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597455):
ten actual HybridWebView UI cases, nine passing and one expected
baseline failure (`VerifyHybridWebViewWithShadow`, 6.11% screenshot
difference). Shared parser classifies the real results without the
former missing-helper exception. No with-fix run is claimed. |

For all ten outcomes, bounded artifact export, fresh MauiBot
publication, actual stored HTML, reviewed head, appropriate gate
signals, and lock cleanup are verified. At these execution sources,
reports rendered four badges and closed Gate analysis/Follow-up
accordions; test-group tables were rendered when evidence existed, while
the no-tests control truthfully had no test table. The user-requested
in-place simplification below now removes Scope and Follow-up from those
same reports. Available excerpts remain escaped and detailed execution
evidence stays in bounded artifacts. Replaced owned reports are
independently confirmed minimized as outdated. Intentional FAILED
verdicts remain red even when publication and cleanup succeed. Missing
iOS result files are unverified execution, not demonstrated flakes or
proof that the target PR is wrong. A passing gate is not full coverage,
a code review, or merge readiness.

#39179's old Windows attempts at sources before `d4397` could not parse
failure-only results because the snapshot-size helper was declared after
that branch exited. The older corrective
[15597112](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597112)
published and cleaned up successfully but did **not** validate the
helper fix. Final
[15597455](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597455)
validates the exact helper source and retains the 156,762-byte
`test-failure-HybridWebViewFeatureTests.log`. Its author advanced the
raw reviewed head from `63621b4f8254b5a4112b1dbac3e676633544ca52` to
`0d16b9cc87ef5640e176a2666e02c269ebdd6ce7` before final dispatch; those
identities remain separate. Final reviewed/live head is unchanged, only
the passing gate signal is present, and the lock is absent. The final
build is `partiallySucceeded` because of its initial WSL preparation
warning; protected-base recovery, actual Gate, export, fresh
publication, and cleanup succeeded. Native Windows provisioning at
source `ecd602ef` is separately verified below.

**Canary-exposed corrections:**

- Source `78bb5d3a3bc6da91357b5b116542d77bcc283449`: explicitly exit
successfully after checked publication so an accepted optional
label-removal 404 cannot leak a native exit code into PowerShell@2.
Required API errors still throw. Bound/truncate allowlisted optional
transcripts rather than rejecting all GateLogs when a transcript is
oversized. Select the containing unit fixture instead of broad nested
`Resize` (597 cases became the intended 16). Corrective SKIPPED,
intentional FAILED, and INCONCLUSIVE publications and cleanup complete
successfully.
- Source `d4397eaa8b855209c963ea8aad201508c3d45c05`: move the unchanged
snapshot-size parser helper before shared parsing and both verification
modes; retain bounded `test-failure*.log` diagnostics. Updated related
documentation. PowerShell parsing of both changed scripts and `git diff
--check` passed. `Invoke-Pester -Path
@('.github/skills/verify-tests-fail-without-fix/scripts/Verify-TestsFail.Tests.ps1',
'.github/scripts/shared/Export-ExpectedPRAgentArtifact.Tests.ps1',
'.github/scripts/shared/Copy-BoundedDiagnosticFile.Tests.ps1',
'.github/scripts/shared/Import-ExpectedPRAgentArtifact.Tests.ps1')
-Output Minimal -PassThru` — **141 passed**, zero
failed/skipped/inconclusive/not-run. No new pipeline/configuration tests
were written. Actual Windows failure-only parser/log-export/publication
verification passed in
[15597455](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597455).
- Source `ecd602ef48662a2a59f083d9db8fc5bdfb83fd45`: select a native
PowerShell child for the Windows MSBuild-task watchdog instead of system
`bash` that selected unconfigured WSL on Windows-2022. Retain the
existing Unix command, wall-clock bound, output sanitization, exit-code
propagation, and retry markers. YAML parsing, all eight embedded
PowerShell blocks, the Windows child command, and `git diff --check`
passed; no pipeline tests were added. The additional [Windows bootstrap
control
15597596](https://dev.azure.com/DevDiv/DevDiv/_build/results?buildId=15597596),
on already-selected no-tests PR #39213 at unchanged head
`1021c9a53afc990312bd6be5cea48dd56205c96f`, **completed successfully at
this exact source**. MSBuild tasks actually built on the first attempt
in 3m10s, with zero errors and no WSL/retry failure. Its bounded report
is SKIPPED; fresh MauiBot
[6038579070](#39213 (comment))
rendering, absence of pass/fail signals, prior-owned minimization,
export, publication, and cleanup are verified. No native tests are
claimed for this control; it is not a substitute for the separate
Windows helper execution.

**User-requested compact presentation at source
`e41058bb0798ed6dddabcb1fda339d532bf2f145`:**

- Remove the Follow-up accordion and its unused next-action logic, the
Scope badge/text, and the report/artifact-link footer. Keep
Result/Platform/Commit badges, Gate analysis, nuanced verdicts, test
tables, escaped excerpts, and pinned head/baseline identities. Update
both relevant report-format documentation sections. Publication
ownership, ordering, labels, minimization, and artifact limits are
unchanged.
- Publisher PowerShell AST parsing and `git diff --cached --check`
passed. Production `Post-PRGate.ps1 -DryRun` and actual GitHub Markdown
rendering passed using retained evidence for full-mode PASSED (#38441),
compile-coupled PASSED (#38625), failure-only PASSED (#39179), FAILED
(#37319), SKIPPED (#39213), and INCONCLUSIVE (#37690). Each has three
badges and closed Gate analysis without Scope, Follow-up, or the footer;
test tables and escaped log contents remain unchanged. No new pipeline
tests or native verification reruns were added.
- All ten report URLs above were updated **in place** with separately
guarded maintainer edits after freshly checking each comment's exact
body, update timestamp, owner, ID, and run marker. The publisher was not
run under the maintainer's identity. Actual stored `body_html` read-back
verifies the same MauiBot comment IDs and unchanged verdicts, commit
identities, test tables, and log text. These are presentation-only edits
of existing evidence, not new Azure Gate runs or new comments.

</details>

The additive correction, remote canary verification, earlier ten-PR
verification, and compact comment presentation are complete and pushed.
This PR remains **draft** while normal CI finishes; no merge readiness
is claimed. The earlier model-policy and skill-harness failures are
preserved above as source-specific evidence, not silently repaired or
described as green. After this PR merges, `/review` continues the full
process and `/review gate` selects only existing-test verification.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

N/A - requested additive gate-only review and report-presentation
changes; #38807 is the initial report-layout reference, not an issue
fixed by this PR.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 5 findings

Reviewed commit ab92585.

See inline comments for details.

HttpResponseMessage response = null;
try
{
response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Logic and Correctness Verification - ResponseHeadersRead ends HttpClient's request timeout when the headers arrive, but no replacement deadline covers the response body. If a server sends successful headers and one byte of an image, then stalls without closing the connection, the default-token path waits indefinitely in UriImageSourceCache.CopyToCacheAsync while holding the per-URI lock; other sources requesting that URI also remain blocked. Previously the default HttpClient timeout covered buffering the entire response. Preserve a bounded body-read lifetime, including uncached streams returned to callers. The explicit-cancellation tests do not cover a stalled body without caller cancellation.

Func<CancellationToken, Task<Stream?>> download,
Action<Exception> cacheError,
CancellationToken cancellationToken) =>
GetStreamAsync(uri, cacheValidity, download, FileSystem.CacheDirectory, cancellationToken, cacheError);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Logic and Correctness Verification - FileSystem.CacheDirectory is evaluated before entering any cache-I/O recovery block. On unpackaged Windows applications its getter creates the cache directory; if creation throws IOException or UnauthorizedAccessException, download is never invoked and a reachable URI image fails instead of falling back to the network. Even CacheValidity=TimeSpan.Zero hits this getter before reaching the bypass in the other overload. Include directory resolution in recoverable cache setup and bypass it for nonpositive validity. CacheWriteFailureStillReturnsDownloadedImage passes a directory directly to the internal overload, so it misses this production entry-point failure.


downloaded.Dispose();
downloaded = null;
reservation.Dispose();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Logic and Correctness Verification - The temporary-byte reservation is released before publication, although a failed Move/Replace returns a TemporaryFileStream retaining the complete .tmp file until disposal. Those files then count toward neither budget: the reservation is zero and TrimCache excludes .tmp files. Extending CachePublishFailureReturnsFirstDownload to two 20 MiB downloads while retaining both returned streams leaves 40 MiB of temporary files despite the 25 MiB aggregate temporary limit; repeated loads can grow this without bound even when callers eventually dispose every stream. Transfer the reservation to TemporaryFileStream on publication failure, releasing it after publication or temporary-file cleanup.

if (stream == null)
throw new InvalidOperationException("Unable to load image stream.");

var seekableStream = await stream.EnsureSeekableAsync(cancellationToken);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - The changed Windows stream-to-bitmap path has no regression test: the added Controls tests read arbitrary bytes through IStreamImageSource, and the device-test addition is iOS-only. None exercises EnsureSeekableAsync or BitmapImage.SetSourceAsync. CachingEnabled=false now supplies a live non-seekable HTTP stream, whereas a cache hit supplies a seekable FileStream; removing the adapter or its rewind would leave the added tests unchanged while breaking Windows image loading. Add a Windows test using an encoded image through GetImageSourceAsync for the non-seekable uncached and seekable cache-hit paths, asserting decoding and cache reuse. This covers the platform named in #9138, not only the managed byte cache.

};
Assert.Equal(0, networkcalls);
networkCalls++;
return Task.FromResult<Stream>(new MemoryStream([1, 2, 3, 4]));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - This oversized fixture never exercises the composite stream's file-prefix or network-tail data. CopyToCacheAsync requests 81920 bytes, so the four-byte MemoryStream is consumed in one read and immediately exceeds the three-byte limit: the temporary file is empty, all bytes enter Overflow, and the network stream is already at EOF. The assertions still succeed if TemporaryAndNetworkStream drops either its file or network segment. Use a chunk-limited source that writes a nonempty prefix within the limit, then overflows while leaving unread tail bytes; assert exact byte order through synchronous and asynchronous reads and cleanup on disposal.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 17, 2026
@MauiBot

MauiBot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@jfversluis — existing-test verification for commit ab925857.

Result INCONCLUSIVE Platform iOS Commit ab925857


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

🧪 Unit tests
Test group Without fix With fix
UriImageSourceTests ⚠ Build blocked ✅ Passed (25s)
📱 Device tests
Test group Without fix With fix
UriImageSourceServiceTests (CachedImageHonorsCacheValidity) ⚠ Build blocked ⚠ Environment blocked
Execution log excerpts

Without fix UriImageSourceTests

/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(377,29): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(397,20): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(399,21): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(425,20): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(429,21): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(452,5): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/UriImageSourceTests.cs(454,29): error CS0103: The name 'UriImageSourceCache' does not exist in the current context [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.

With fix UriImageSourceTests

StoreResponseIsReturnedButNotCached [2 ms]
  Passed CancellationAfterHeadersAbortsUncachedResponseBody [2 s]
  Passed CachingEnabledControlsHttpRequests(cachingEnabled: True, expectedRequests: 1) [6 ms]
  Passed CachingEnabledControlsHttpRequests(cachingEnabled: False, expectedRequests: 2) [2 ms]
  Passed HttpCancellationIsPropagatedAndNotCached [3 ms]
  Passed CacheWriteFailureStillReturnsDownloadedImage [1 ms]
  Passed SlowStreamingResponseIsFullyCached [106 ms]
  Passed NullUriDoesNotCrash [< 1 ms]
  Passed CachePublishFailureReturnsFirstDownload [4 ms]
  Passed SameUriHasSameCachePath [< 1 ms]
[xUnit.net 00:00:03.03]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed DifferentUrisHaveDifferentCachePaths [1 ms]
  Passed OversizedImageIsReturnedButNotCached [4 ms]
  Passed ZeroValidityAlwaysDownloads [< 1 ms]
  Passed CancellationDoesNotCreateCacheEntry [1 ms]
  Passed TrimCacheRemovesOldestFilesAndStaleTemporaryFiles [1 ms]
  Passed SecondCallLoadsFromCache [2 ms]
  Passed OpenCachedStreamDoesNotPreventRefresh [3 ms]
  Passed CacheMissReturnsFileStreamWithoutBufferingImageInMemory [2 ms]
Test Run Successful.
Total tests: 23
     Passed: 23
 Total time: 3.2940 Seconds

Without fix UriImageSourceServiceTests (CachedImageHonorsCacheValidity)

/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Services/ImageSource/UriImageSourceServiceTests.iOS.cs(61,25): error CS1501: No overload for method 'IsImageCached' takes 2 arguments [/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Core.DeviceTests.csproj::TargetFramework=net10.0-ios]
/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Services/ImageSource/UriImageSourceServiceTests.iOS.cs(65,26): error CS1501: No overload for method 'IsImageCached' takes 2 arguments [/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Core.DeviceTests.csproj::TargetFramework=net10.0-ios]
/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Services/ImageSource/UriImageSourceServiceTests.iOS.cs(66,26): error CS1501: No overload for method 'IsImageCached' takes 2 arguments [/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Core.DeviceTests.csproj::TargetFramework=net10.0-ios]
/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Services/ImageSource/UriImageSourceServiceTests.iOS.cs(67,25): error CS1501: No overload for method 'IsImageCached' takes 2 arguments [/Users/cloudtest/vss/_work/1/s/src/Core/tests/DeviceTests/Core.DeviceTests.csproj::TargetFramework=net10.0-ios]
Build FAILED.

PR head: ab925857.

Without-fix baseline: 3a7d7287.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 17, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Dec 1, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) and removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Stopped

@kubaflo ❌ The last fix round found nothing more it could fix. Decide how to continue, or comment /review autopilot to run it again.

Why

No merge commit was published: main now routes URI image streams through a shared loader that buffers the response, while this PR requires streaming to bounded disk storage without buffering the whole image. Taking either side would drop that streaming behavior or bypass the configured loader and IImageCache; preserving both requires adding streaming support to the shared loader, beyond this conflict-only round.

[Run](https://github.com/dotnet/maui/actions/runs/46548014002).

@github-actions github-actions Bot added the s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue label Dec 1, 2026

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 7039e4f1 Deployed Aug 20, 2026 by jfversluis via conclusion #1449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-image Image control platform/ios platform/macos macOS / Mac Catalyst s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UriImageSource caching not implemented for Windows & check TODO comments around caching in general

3 participants