-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Carousel issue - Canvas: trying to use a recycled bitmap android.graphics.Bitmap #10032
Comments
I found out this issue happens only in Debug mode. It works fine in Release mode. |
@mattleibow @rmarinho any additional thoughts? |
I wonder if we just need to stop explicitly disposing images and let glide do it for us. In the image source service, we probably need to dispose when we are returning bitmap/drawable, but do nothing when loading into an image view. |
Could you attach a small sample where reproduce the issue? |
Same issue on Android (it works in Windows the first time only : if I go from last image to first image again, nothing happens anymore). I try to switch the background image of a page. Each second, I change the image. Here is some basic code to reproduce the bug : on MainPage.xaml.cs And in MainPage.xaml : |
I get the same using a CarouselView with an Image in the ItemTemplate. Android 13 with .NET 7 GA tooling.
Here is a repro. Just scroll and scroll until it eventually happens. Usually not very long. https://github.com/espenrl/issue-repro/tree/main/CarouselView-android-recycled-bitmap |
Same Issue here in CollectionView |
Yep, just experienced the same issue with the CollectionView on Android. Any workarounds for now? |
For me it occurs in release mode. |
https://developer.android.com/topic/performance/graphics/manage-memory perhaps this helps and this Unfortunately this bug is so unpredictable in the current implementation we cannot release anything on maui to the public. it could blow up on any device at any time as we've seen on our test devices. Regards |
same here. we are about to release the app to public, but we can´t. The error randomly happens. This is really a show stopper! |
This happens for CarouselView and CollectionView. I forgot: in my case this happens primarily in release mode. |
Example error: Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualBooleanMethod(JniObjectReference , JniObjectReference , JniMethodInfo , JniArgumentValue* ) |
another one: Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference , JniObjectReference , JniMethodInfo , JniArgumentValue* ) |
Hope this helps to nail down the problem |
The same issue... |
Hope the team get the importance of this. It's a fundamental building block of all these views that images are handled correctly as a base requirement, there cannot be any room for error otherwise your app will just crash and along with it your brand image. Without this it is not possible to release any Maui app at this time unfortunately. Luckily mine was a port from Xamarin, so I've reworked the changes back into the old app that the Maui port was going to replace and will revisit in another 3 to 6 months time to see if things have improved. Incidentally the performance of the scrolling in the Maui app also would not have let us release either, but that is a different topic. |
@1357310795 |
This might need retagging. It looks as though it is unrelated to the This obviously will impact any Android Control that uses the |
I don't know if it has something to do with it, but with |
any solution to |
@jsuarezruiz @mattleibow @PureWeen @hartez @davidortinau @maddymontaquila This bug has been declared multiple times and the first time in June 2022. When do you plan to fix it. The bug is rated high but no one is taking care of it. How do you expect us to trust Maui if the same Xamarin Forms slow fix issues happen again. As part of my company we are seriously considering moving to another technology (native or flutter). We're tired of always having to find workarounds ! |
I spent a few hours to analyze this problem. This bug was created following this pull request: #7348 While waiting for Microsoft to permanently fix this bug, the workaround consists of redoing the clear before each source image change. Below is an example of code to add the clear in the source image mapping. This workaround is applicable to the following bug
|
@mohachouch |
I'm struggling to understand how an issue as prominent as this one, a hard crash on android when simply displaying an image and tabbing away and back, has been seemingly ignored for so long and even moved to the backlog (on another referenced similar issue). Thanks a lot @mohachouch for your time investigating and seemingly finding a workaround. Will definitely try this one later today. |
@mohachouch |
Your welcome @FM1973 I remind you that the workaround is not a correction, it's just for waiting a more permanent fix. I noticed an strange thing, in my case I don't have to clear but just to declare the method is enough to fix the bug. @FM1973 can you check that it works on your side ? Not applying this workarround does not work for everyone
According to the source code, assignment of item is done asynchronously, may be related to that : https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/Image/ImageHandler.Android.cs#L51 |
@mohachouch |
@mohachouch |
@mohachouch @1357310795 |
Thank you for the tests, I do not understand why on my test it works. It's safer to clear anyway while waiting for Microsoft's fix. |
Description
I am using CarouselView in .Net Maui, I have four image Urls that I assign to an Image component inside a CarouselView, my code is as below:
In the first round, when I slide through images, it works perfectly but crashes in the second round after the first or second image.
When I debug, it shows the exception below:
Java.Lang.RuntimeException: 'Canvas: trying to use a recycled bitmap android.graphics.Bitmap@bb33eb5'
My images are large and if I resize them the issue may be resolved, but I believe it should be a way to disable recycling images, in case there is no way to resize them.
Steps to Reproduce
Link to public reproduction project repository
N/A
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android Version 9 - API 28, Emulator Android 11.0 API 30
Did you find any workaround?
I noticed if I add CurrentItemChangedCommand to the CarouselView it will happen later on Emulator(Sometimes at the third round)
Relevant log output
No response
The text was updated successfully, but these errors were encountered: