Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I have a sample application that shows the issue:
1. Run the sample app on Android
2. Click the "Show The Circle Form" button
3. Click the "Grow Circle" button
4. Navigate back one page.
5. Repeat steps 2 and 3
The crash is caused by a memory leaked instance of the control attempting to redraw after it has been "partially" disposed.
It there was a way for the control to know that it was being disposed/destroyed, I could unsubscribe to the events that cause the crash. On iOS the custom renderers OnElementChanged method is called with a newValue of null and an oldValue that is non Null indicating that I can unsubscribe my events. If we could make that happen on Android, that would be great or any consistent call to the renderer or the control would work.
I have check this issue with the help of sample app attached in Bug description and able to reproduce it. I observed that when I click "Show The Circle Form" button, click "Grow Circle" button, navigate back and again repeat same process then getting exception "System.ArgumentException: 'jobject' must not be IntPtr.Zero.".
Debug Output: https://gist.github.com/saurabh360/67062b8de3895e77d419
Xamarin log: https://gist.github.com/saurabh360/68f8e9a9597fd28ace6d
Environment Info :
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Xamarin 3.9.346.0 (d6de844)
Xamarin.Android 220.127.116.11 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS 18.104.22.168 (862702c6b8aa14a373e25f83ac45918556af41a2)
Xamarin.iOS Unified Migration 1.0
Circle radius changes should fire an INotifyPropertyChange that the customer renderer sees and then applies to the platform view. I see no logic in the renderer to test for the interception of radius property changing. I see no logic in the renderer to test for the interception of radius property changing. Instead, an event is attached to OnRenderChange that directly manipulates the view. Review the documentation for creating a renderer.
That may be so, but that is not the issue here. There needs to be a way for a custom control to clean up its resources if it is being destroyed. Currently there is a way in iOS, but not for Android. With this very simple example, what you propose would eliminate the event handling in the control, but my real controls are quite a bit more complicated.
Internally we detach events in an override of dispose. We are aware of the asymmetry of OnRendererChange between iOS and Android and would like to unify them except, unfortunately, it would be a breaking change. If the dispose approach doesn't work for you please feel free to submit a reduced reproduction of your use case and we'll be happy look at it.
Xamarin Forms Team
Thank you for your bug report. As we have not received the information requested, we cannot properly triage your bug and are marking it resolved.
Xamarin Forms Team