[Windows] Fix AspectFit image fills container regression causing UI test failures on candidate branch - #35923
Merged
kubaflo merged 1 commit intoJun 15, 2026
Conversation
sheiksyedm
marked this pull request as ready for review
June 15, 2026 17:11
kubaflo
approved these changes
Jun 15, 2026
jfversluis
added a commit
that referenced
this pull request
Jun 24, 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! ### Description Updates `eng/scripts/get-maui-pr.sh` and `eng/scripts/get-maui-pr.ps1` so users can still apply PR package artifacts when the aggregate `maui-pr` build is red because of unrelated CI legs, as long as the package-producing artifacts exist for the current PR commit. ### Changes - Treat a red aggregate `maui-pr` build as a warning instead of an immediate abort. - Keep `PackageArtifacts` as the hard gate before downloading/applying packages. - Filter AzDO fallback builds to the current PR head/merge context using `triggerInfo.pr.sourceSha`, `sourceVersion`, and the PR merge SHA. - Warn when `Pack macOS` or `Pack Windows` timeline records do not report success. - Update troubleshooting text to refer to completed `maui-pr` builds with `PackageArtifacts` rather than green checks. ### Validation - `bash -n eng/scripts/get-maui-pr.sh` - PowerShell parser validation for `eng/scripts/get-maui-pr.ps1` - `git diff --check` - Local throwaway MAUI projects under `/Volumes/NieuwVolume/maui-pr-artifact-verification-20260616101523`: - PR `#35805`: red aggregate build `1461390`, `PackageArtifacts` present, pack jobs succeeded; Bash and PowerShell scripts applied package `10.0.80-ci.pr35805.26312.37`; `dotnet restore` succeeded. - PR `#35923`: green aggregate build path applied package `10.0.80-ci.pr35923.26315.57`; `dotnet restore` succeeded. - PR `#35626`: missing `PackageArtifacts` failed before mutating the project. - PR `#999999`: nonexistent PR failed cleanly during PR lookup. - Wrong-SHA harness for PR `#35805`: refused to use older completed builds when none matched the requested head/merge commit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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 from this PR and let us know in a comment if this change resolves your issue.
Thank you!
Root Cause
PR #34699 introduced
_cachedImageSizeto eliminate timing-dependent behavior inGetDesiredSize(). As part of that change,MapSourceAsync()resets the cache toZerowhenever a new image source is assigned.However,
GetDesiredSize()was updated to rely exclusively on_cachedImageSizeand no longer considered the live decoded size available onBitmapSource. This created a timing gap where WinUI had already completed image decoding and populatedBitmapSource.PixelWidth/PixelHeight, but the asynchronousImageOpenedevent had not yet fired to update the cache.If a layout pass occurred during this window,
GetDesiredSize()observed a zero-sized cache, skipped the natural-size constraint, and allowed the image to expand to the available container size instead of respecting its decoded pixel dimensions.Description of Change
Two minimal updates were made in
ImageHandler.Windows.cs:GetDesiredSize()BitmapSourcefirst._cachedImageSizeonly when the live size is not yet available.UpdatePlatformMaxConstraints().GetImageSize()PlatformViewto prevent a potential null-reference exception whenGetDesiredSize()is called after handler disconnection.Regression Introduced By
PR #34699
Issues Fixed
Fixes the following candidate branch regressions:
In
Issue30403SmallImages.csfile:ConstrainedContainers_ShouldHandleSmallImagesSmallImageEndAlignment_ShouldRespectAlignmentSmallImageInLargeContainer_ShouldNotExceedIntrinsicSizeSmallImageStartAlignment_ShouldRespectAlignmentSizeComparison_ShouldShowDifferentSizesTinyImage_ShouldRemainTinyTested the behaviour in the following platforms