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.
Created attachment 22597 [details]
When a Page that contains a custom ViewRenderer control is popped, it results in a NRE on UWP. This is because the Page is being cleaned up during the pop which results in the custom renderer being disposed in VisualElementRenderer. However during disposal, this line causes OnElementChanged() to be called and because Control has also been set to null, the custom renderer goes through the new control creation process and fails since parts of the renderer have already been disposed.
Crash stack trace: https://gist.github.com/jimmgarrido/febd9e9af98000442ae97f5c77a9964e
I'm attaching a minimized repro project from a user. This does _not_ happen on iOS or Android, and looking at those platforms it looks like most of the disposal handling occurs in the derived renderers and not VisualElementRenderer.
### Steps to Reproduce
1. Run the UWP project
2. Click "Go"
3. Go back to the first page
### Expected results
The app navigates back to the first page
### Actual results
The app crashes
### Version Tests
Use a local variable in the custom ViewRenderer to track if it is being disposed and if it is being disposed, return from OnElementChanged() before it tries to create a new control.
Please review the following for an example of how to implement OnElementChanged:
When implementing a CustomRenderer in a manner unexpected by XF you may likely encounter NRE or other exceptions that are not as descriptive as you might expect as a user of XF. We will work to trap for these conditions and throw more descriptive errors.
Should be fixed on 2.3.6-pre1 with a better error message.