Skip to content

[Windows] Fixed COMException when changing Image Aspect to Fill#34033

Draft
SubhikshaSf4851 wants to merge 1 commit intodotnet:mainfrom
SubhikshaSf4851:Fix-29812
Draft

[Windows] Fixed COMException when changing Image Aspect to Fill#34033
SubhikshaSf4851 wants to merge 1 commit intodotnet:mainfrom
SubhikshaSf4851:Fix-29812

Conversation

@SubhikshaSf4851
Copy link
Contributor

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:

On Windows, changing the image AspectFill was triggering updates before the native PlatformView was fully loaded, causing a lifecycle timing issue that resulted in a COMException when accessing the underlying WinUI image control.

Description of Change

  • Updated the MapAspect method in ImageHandler.Windows.cs to check if the PlatformView is loaded before updating the aspect, and to attach a Loaded event handler (OnImageLoaded) if it is not yet loaded.
  • This ensures that aspect updates and container view updates occur at the correct time, preventing issues related to view initialization order.

Test Coverage Adjustments:

  • Removed the #if TEST_FAILS_ON_WINDOWS preprocessor directive from ImageFeatureTests.cs, re-enabling tests for verifying image aspect with image sources from files and fonts on Windows. This change ensures these tests are now executed across all platforms, improving test coverage. [1] [2]

Issues Fixed

Fixes #29812

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforrFix29812.1.mp4
AfterFix29812.mp4

@dotnet-policy-service
Copy link
Contributor

Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

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

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Runtime.InteropServices.COMException thrown when setting Image.Aspect = AspectFill via data binding on Windows

2 participants