-
Notifications
You must be signed in to change notification settings - Fork 546
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
(XF/Android) Exception occurs when GC collects : "System.ObjectDisposedException: Cannot access a disposed object." #292
Comments
Hi @benevbright I will look into this. I where the problem starts, my dispose method is trying to release the bitmap - which for some reason is already released. This technically should not happen since after releasing, the bitmap is set to null. Can you provide more info as to what is causing the issue? Maybe you are scrolling a list view and then this happens? Is it during some page navigation? I need to be able to do some test - it may be that something is happening on another thread, and then the view is being disposed of twice simultaneously. The finalizer is the result of the GC, but if this view was cleaned up in any way, my field will be null. If the bitmap is being cleaned up somewhere then something is still wrong as I still have my field referencing it. It might be that the GC is collecting both at the same time, which is weird still. Any further info as what is happening at the time of the crash will be helpful. |
Hi, Matthew. I made a repro sample project which has a similar layout as my project. The difference between the sample and my project is that it's really hard to reproduce this exception. CLUE : likely it may happen when SkiaCanvas's isVisible property to 'false'. Tested on Xamarin.Forms 2.3.4.231 / SkiaSharp 1.57.1 / Mac Android Player(Nexus 4) / Android SDK API 25. But because It's too hard to reproduce, I can not say it's a problem of SkiaSharp.
|
My users report the same issue. |
I have the same issue with Mapsui from pauldendulk which uses SkiaSharp. It looks like this exception comes always when a huge amount of memory is allocated. I got the exception everytime when my app uses a lot of RAM. Even if I navigate away from the Map which is the only usage of SkiaSharp, this exception comes up as soon as I hit about 2.5-3.2GB RAM usage (depends on the amount of background processes). I tried to force the cleanup from the memory at the right moment but it dosn't change a bit. Edit: This problem only occures on Android. On iOS the app runs fine, so I guess the cleanup works there.
|
Just a note about repro: I managed to repro the easily by using It failed every time after the third collect. The reason for this is that the finalizer is collecting the bitmap underneath me. When I call |
The new dispose logic is this
Although a bit scary, at least the GC is releasing the bitmap :) |
Just pushed out a release that should resolve this: https://github.com/mono/SkiaSharp/releases/tag/v1.58.1 |
Always thanks, Matthew. |
Cool! Thanks a lot! |
Have exactly the same problem in my code. |
@Tsukrov Can you provide a stack trace and details about the version of forms, the device and anything else that you may be doing differently? |
Reopening as this is still an issue. I will investigate this further. |
- we shouldn't be referencing managed objects in the finalizer
Hi Matthew, i encountered a similar problem but with the SKDocument object, more specifically the underlying Stream.
I could provide some repro demo project if its desired. |
- we shouldn't be referencing managed objects in the finalizer
- we shouldn't be referencing managed objects in the finalizer
- we shouldn't be referencing managed objects in the finalizer
- we shouldn't be referencing managed objects in the finalizer
Hi Matthew,
Could you look this exception?
When GC collects to make a room (automatically), this exception occurs and app crashes only on XF/Android.
I'm using SKCanvasView at many places.
I found this because the crash report tool received this crash from many users since I released new update SEVERAL DAYS ago. (It's released with SkiaSharp.1.57.0, and before release was on Feb)
skiasharp ver : 1.57.1
XF ver : 2.3.4.231
(UPDATE)
Unfortunately, I tested with 1.56.0 which was included on my Feb release, but the same exception occurs. I guess XF changed how GC handles or other problem.
In my new update, SkCanvas Views are used at many more places, where ListViewCell, ModalPage, CarouselView on Modal, etc.
And Xamarin.Android and I changed even Android SDK since Feb release, so many things are changed.
It's hard to find the reason.
The text was updated successfully, but these errors were encountered: