Skip to content

[Windows] Fix for PickPhotosAsync throws exception if image is modified#32952

Merged
jfversluis merged 1 commit intodotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-32408
Dec 9, 2025
Merged

[Windows] Fix for PickPhotosAsync throws exception if image is modified#32952
jfversluis merged 1 commit intodotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-32408

Conversation

@HarishwaranVijayakumar
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!

Issue Details

  • PickPhotosAsync throws an ObjectDisposedException when size or compression options are used.

Root Cause of the issue

  • The method ApplyMetadataAsync in ImageProcessor.windows.cs returns the same stream that was passed in. However, on iOS and Android, it returns a new stream. After ApplyMetadataAsync completes, the old stream is disposed. On Android and iOS, this is fine because a new stream is returned, so disposing the old one has no effect. But on Windows, since the same stream is returned and then disposed, accessing it afterward causes an exception.

Description of Change

  • Resource management improvement:
    • In ImageProcessor.shared.cs, updated the logic to only dispose outputStream if ApplyMetadataAsync returns a different stream, preventing unintended disposal on platforms (like Windows) where the same stream may be returned.

Issues Fixed

Fixes #32408

Tested the behaviour in the following platforms

  • - Windows
  • - Android
  • - iOS
  • - Mac

Output

Before After
BeforeFix.mp4
AfterFix.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 2, 2025
@dotnet-policy-service
Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 2, 2025
@sheiksyedm sheiksyedm marked this pull request as ready for review December 2, 2025 11:45
Copilot AI review requested due to automatic review settings December 2, 2025 11:45
@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an ObjectDisposedException in PickPhotosAsync on Windows when using image size or compression options. The root cause was that ApplyMetadataAsync returns the same stream on Windows (and other platforms in error paths), but the code was unconditionally disposing the stream after the method call, making it unusable.

Key Changes:

  • Added a reference equality check before disposing outputStream after ApplyMetadataAsync
  • This prevents disposing a stream that's still needed when the same stream instance is returned
  • The fix applies to all platforms since they all can return the same stream in various scenarios

@jfversluis jfversluis changed the base branch from main to inflight/current December 9, 2025 10:26
@jfversluis jfversluis added this to the .NET 10.0 SR3 milestone Dec 9, 2025
@jfversluis jfversluis merged commit 8cb04bf into dotnet:inflight/current Dec 9, 2025
1 check passed
PureWeen pushed a commit that referenced this pull request Dec 10, 2025
PureWeen pushed a commit that referenced this pull request Dec 16, 2025
github-actions bot pushed a commit that referenced this pull request Dec 22, 2025
PureWeen pushed a commit that referenced this pull request Dec 22, 2025
github-actions bot pushed a commit that referenced this pull request Dec 24, 2025
PureWeen pushed a commit that referenced this pull request Dec 26, 2025
github-actions bot pushed a commit that referenced this pull request Dec 27, 2025
PureWeen added a commit that referenced this pull request Dec 29, 2025
## CollectionView
- Fixed the NRE in CarouselViewController on iOS 15.5 & 16.4 by
@Ahamed-Ali in #30838
  <details>
  <summary>🔧 Fixes</summary>

- [NRE in CarouselViewController on iOS 15.5 &
16.4](#28557)
  </details>

- [iOS, macOS] Fixed CollectionView group header size changes with
ItemSizingStrategy by @NanthiniMahalingam in
#33161
  <details>
  <summary>🔧 Fixes</summary>

- [[NET 10] I6_Grouping - Grouping_with_variable_sized_items changing
the 'ItemSizingStrategy' also changes the header
size.](#33130)
  </details>

## Flyout
- Add unit tests for TabBar and FlyoutItem navigation
ApplyQueryAttributes (#25663) by @StephaneDelcroix in
#33006

## Flyoutpage
- Fixed the FlyoutPage.Flyout Disappearing When Maximizing the Window on
Mac Platform by @NanthiniMahalingam in
#26701
  <details>
  <summary>🔧 Fixes</summary>

- [FlyoutPage.Flyout - navigation corrupted when running om mac , on
window ok](#22719)
  </details>

## Mediapicker
- [Windows] Fix for PickPhotosAsync throws exception if image is
modified by @HarishwaranVijayakumar in
#32952
  <details>
  <summary>🔧 Fixes</summary>

- [PickPhotosAsync throws exception if image is
modified.](#32408)
  </details>

## Navigation
- Fix for TabBar Navigation does not invoke its
IQueryAttributable.ApplyQueryAttributes(query) by @SuthiYuvaraj in
#25663
  <details>
  <summary>🔧 Fixes</summary>

- [Tabs defined in AppShell.xaml does not invoke its view model's
IQueryAttributable.ApplyQueryAttributes(query)
implementaion](#13537)
- [`ShellContent` routes do not call
`ApplyQueryAttributes`](#28453)
  </details>

## ScrollView
- Fix ScrollToPosition.Center behavior in ScrollView on iOS and
MacCatalyst by @devanathan-vaithiyanathan in
#26825
  <details>
  <summary>🔧 Fixes</summary>

- [ScrollToPosition.Center Centers the First Item too in iOS and
Catalyst](#26760)
- [On iOS - ScrollView.ScrollToAsync Element,
ScrollToPosition.MakeVisible shifts view to the right, instead of just
scrolling vertically](#28965)
  </details>

## Searchbar
- [iOS, Mac, Windows] Fixed CharacterSpacing for SearchBar text and
placeholder text by @Dhivya-SF4094 in
#30407
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS, Mac, Windows] SearchBar CharacterSpacing property is not
working as expected](#30366)
  </details>

## Shell
- Update logic for large title display mode on iOS - shell by @kubaflo
in #33039

## TitleView
- [iOS] Fixed memory leak with PopToRootAsync when using TitleView by
@Vignesh-SF3580 in #28547
  <details>
  <summary>🔧 Fixes</summary>

- [NavigationPage.TitleView causes memory leak with
PopToRootAsync](#28201)
  </details>

## Xaml
- [C] Fix binding to interface-inherited properties like
IReadOnlyList<T>.Count by @StephaneDelcroix in
#32912
  <details>
  <summary>🔧 Fixes</summary>

- [Compiled Binding to Array.Count provides no
result](#13872)
  </details>

- Fix #31939: CommandParameter TemplateBinding lost during reparenting
by @StephaneDelcroix in #32961
  <details>
  <summary>🔧 Fixes</summary>

- [CommandParameter TemplateBinding Lost During ControlTemplate
Reparenting](#31939)
  </details>


<details>
<summary>🧪 Testing (4)</summary>

- [Testing] Fixed Test case failure in PR 33185 - [12/22/2025] Candidate
by @TamilarasanSF4853 in #33257
- [Testing] Re-saved ShouldFlyoutBeVisibleAfterMaximizingWindow test
case images in PR 33185 - [12/22/2025] Candidate by @TamilarasanSF4853
in #33271
- [Testing] Fixed Test case failure in PR 33185 - [12/22/2025] Candidate
- 2 by @TamilarasanSF4853 in #33299
- [Testing] Fixed Test case failure in PR 33185 - [12/22/2025] Candidate
- 3 by @TamilarasanSF4853 in #33311

</details>

<details>
<summary>📦 Other (2)</summary>

- [XSG][BindingSourceGen] Add support for RelayCommand to compiled
bindings by @simonrozsival via @Copilot in
#32954
  <details>
  <summary>🔧 Fixes</summary>

  - [Issue #25818](#25818)
  </details>
- Revert "Update logic for large title display mode on iOS - shell
(#33039)" in cff7f35

</details>
**Full Changelog**:
main...inflight/candidate
StephaneDelcroix pushed a commit that referenced this pull request Jan 5, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PickPhotosAsync throws exception if image is modified.

3 participants