maui
maui copied to clipboard
[Android] Fix for Resize method returns an image that has already been disposed
[!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
- In GraphicsView, the Resize method returns an image that has already been disposed.
Root Cause
- The Bitmap property returned the internal _bitmap instance directly, which would be disposed during the Dispose() call if disposeBitmap was set to true, potentially leading to access of a disposed object.
Description of Change
- Updated the Bitmap property to return a new bitmap instance using Bitmap.CreateBitmap, ensuring that the original bitmap is not reused after disposal.
Reference
https://github.com/dotnet/maui/blob/acdb6f2246d0a864a030f5526e2d104833b95977/src/Graphics/src/Graphics/Platforms/iOS/PlatformBitmapExportContext.cs#L41-L49
Issues Fixed
Fixes #29961
Validated the behaviour in the following platforms
- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac
Output
| Before | After |
|---|---|
Hey there @@SyedAbdulAzeemSF4852! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
/azp run MAUI-UITests-public
Azure Pipelines successfully started running 1 pipeline(s).