Bug 53221 - System.NullReferenceException on StackLayout Clear at VisualElementPackager.RemoveChild
Summary: System.NullReferenceException on StackLayout Clear at VisualElementPackager.R...
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-03-10 13:37 UTC by Vic
Modified: 2018-04-18 08:42 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED NORESPONSE

Description Vic 2017-03-10 13:37:05 UTC
Error happen when calling StackLayout.Children.Clear():

System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Forms.Platform.Android.VisualElementPackager.RemoveChild (Xamarin.Forms.VisualElement view) [0x00014] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:142 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:128 
  at (wrapper delegate-invoke) System.EventHandler`1[Xamarin.Forms.ElementEventArgs]:invoke_void_object_TEventArgs (object,Xamarin.Forms.ElementEventArgs)
  at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x0000f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:365 
  at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:578 
  at Xamarin.Forms.Layout`1[T].OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:40 
  at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:413 
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:377 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351 
  at System.Collections.ObjectModel.ObservableCollection`1[T].RemoveItem (System.Int32 index) [0x0002b] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:205 
  at System.Collections.ObjectModel.Collection`1[T].Remove (T item) [0x0002d] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:113 
  at Xamarin.Forms.ObservableWrapper`2[TTrack,TRestrict].Clear () [0x00030] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\ObservableWrapper.cs:45
Comment 1 Jimmy [MSFT] 2017-03-10 19:22:37 UTC
Thank you for filing this report! 

Unfortunately I was not able to reproduce this crash with a sample project. I tested with Forms 2.3.3.193 and 2.3.4-pre4 on an Android 6.0 and 4.4 emulator. Can you attach a reproduction project along with any repro steps required so we can continue looking into this? Thanks!
Comment 2 Jimmy [MSFT] 2017-04-11 18:07:55 UTC
Because we have not received a reply to our request for more information in over 4 weeks, we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!
Comment 3 Dharmendar 2017-07-06 04:56:54 UTC
Hi Jimmy, 

No, it is not fixed in Forms 2.3.3.193 and 2.3.4-pre4.I too experiencing same kind of crash in the mentioned version which can be easily replicated clearing children of view inside the master detail page.
Comment 4 Dharmendar 2017-07-06 05:11:14 UTC
This issue can be replicated using below replication procedure.

1.Maintain links for two pages using list view  in master page. Both pages should have loaded with StackLayout loaded with buttons.
2.Navigate to linked pages using list view in master page for two times.
3.Now clear buttons of Stacklayout in first page using some tool bar click action.Issue will reproduce.