Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IImage.Resize on Android always returns an object with **System.ObjectDisposedException:** 'Cannot access a disposed object. #6909

Closed
janseris opened this issue May 6, 2022 · 3 comments
Assignees
Labels
area-controls-image Image control p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@janseris
Copy link

janseris commented May 6, 2022

Description

System.ObjectDisposedException: 'Cannot access a disposed object.
IImage Resize(float width, float height, ResizeMode resizeMode = ResizeMode.Fit, bool disposeOriginal = false);

doesn't matter if disposeOriginal: true or false

When the function is called, the returned object (resized IImage) always has this problem and cannot be used.
However, object returned by Downsize method works fine

Steps to Reproduce

call IImage.Resize() on Android and work with the returned object

Demonstration:

MauiApp2 Android IImage resized image disposed exception.zip

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11 (API 30)

Did you find any workaround?

the same functionality can be simulated using IImage.Downsize() probably

Relevant log output

No response

@janseris janseris added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 6, 2022
@janseris janseris changed the title Resize on Android causes **System.ObjectDisposedException:** 'Cannot access a disposed object. IImage.Resize on Android causes **System.ObjectDisposedException:** 'Cannot access a disposed object. May 6, 2022
@janseris janseris changed the title IImage.Resize on Android causes **System.ObjectDisposedException:** 'Cannot access a disposed object. IImage.Resize on Android always returns an object with **System.ObjectDisposedException:** 'Cannot access a disposed object. May 6, 2022
@Redth Redth added this to the 6.0.300-servicing milestone May 9, 2022
@Eilon Eilon added the area-image Image loading, sources, caching label May 9, 2022
@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label May 10, 2022
@VincentBu
Copy link

repro with vs main (32623.270)

[0:] Loaded image: 960 × 1280
[0:] Downsized image: 800 × 800
[chromium] [INFO:CONSOLE(1)] "Cannot access a disposed object.
[chromium] Object name: 'Android.Graphics.Bitmap'.
[chromium]    at Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:line 152
[chromium]    at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractInt32Method(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 213
[chromium]    at Android.Graphics.Bitmap.get_Width() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-32/mcw/Android.Graphics.Bitmap.cs:line 563
[chromium]    at Microsoft.Maui.Graphics.Platform.PlatformImage.get_Width() in D:\a\_work\1\s\src\Microsoft.Maui.Graphics\Android\PlatformImage.cs:line 18
[chromium]    at MauiApp2.Pages.Index.SelectImageAndResize() in D:\Workspace\MauiRepro\MauiApp2\MauiApp2\Pages\Index.razor:line 34
[chromium]    at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
[chromium]    at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)", source: https://0.0.0.0/_framework/blazor.webview.js (1)

@VincentBu VincentBu added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 24, 2022
@jsuarezruiz jsuarezruiz self-assigned this Jun 30, 2022
@jsuarezruiz
Copy link
Contributor

This issue have been fixed by dotnet/Microsoft.Maui.Graphics#453

@janseris
Copy link
Author

janseris commented Jun 30, 2022

@jsuarezruiz Great, when is this in official version of MAUI? Thank you.

@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Jul 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 11, 2022
@Eilon Eilon added area-controls-image Image control and removed area-image Image loading, sources, caching labels May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-image Image control p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants