Hello, i am developing an fabulous app and currently experiencing weird issue while running my app on real device (Xiaomi mi8 if that does matter anything).
I have a view, which has two "states": first is just a label with "no content" text
and second is a ListView. On first load i am getting the error below. On next view loads all works fine. I am guessing this could be tied to fact that i have two different kind of visual tree in each state and when Fabulous trying to calculate the diff for ObservableCollection, it simpy cannot find the previous one. But anyway, any help and clues of what is going on is greatly appreciated
Unable to update view:: System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.PageRenderer.Xamarin.Forms.Platform.Android.IOrderedTraversalController.UpdateTraversalOrder () [0x000a4] in D:\a\1\sXamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:177
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].UpdateParentPageTraversalOrder () [0x00025] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:404 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00116] in D:\a\1\sXamarin.Forms.Platform.Android\VisualElementRenderer.cs:369
at (wrapper delegate-invoke).invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\sXamarin.Forms.Core\
BindableObject.cs:211
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\sXamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x00094] in D:\a\1\sXamarin.Forms.Core\Element.cs:210
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\sXamarin.Forms.Core\Element.cs:335
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\sXamarin.Forms.Core\VisualElement.cs:750
at Xamarin.Forms.Layout1[T].OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:41 at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:464 at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:427 at (wrap per delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object oldItem, System.Object newItem, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:354 at System.Collections.ObjectModel.ObservableCollection1[T].SetItem (System.Int32 index, T item) [
0x0001c] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:210
at System.Collections.ObjectModel.Collection1[T].set_Item (System.Int32 index, T value) [0x0002b] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:61 at Xamarin.Forms.ObservableWrapper2[TTrack,TRestrict].set_Item (System.Int32 index, TRestrict value) [0x00029] in D:\a\1\sXamarin.Forms.Core\ObservableWrapper.cs:140
at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core .FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x000ec] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:407
at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383 at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320
at.$Xamarin.Forms.[email protected] (Mic
rosoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258 at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x0010e] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:411 at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Micros oft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383
at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320 at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258
at Fabulous.DynamicViews.ViewBuilders.UpdateContentView (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentView target) [0x001c6] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms .Core.fs:6565 at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentView target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:6543
at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x0010e] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:411
at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] co
llOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383 at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320
at.$Xamarin.Forms.[email protected] (Microsoft.FSharp.Core.FSharpValueOption 1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258 at Fabulous.DynamicViews.ViewBuilders.UpdateContentPage (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.
ViewElement curr, Xamarin.Forms.ContentPage target) [0x00239] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12613
at.$Xamarin.Forms.[email protected] (Microsoft.FSharp.Core.FSharpValueOption 1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12585 at Fabulous.DynamicViews.Converters.updateNavigationPages (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, Xamarin.Forms.NavigationPage target, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach) [0x00274] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:694
at Fabulous.DynamicViews.ViewBuilders.UpdateNavigationPage (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00339] in /Git/Github/Fabulous/src/Fabulous.Core/Xamar in.Forms.Core.fs:11975 at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:11927
at Fabulous.Core.ProgramRunner2[model,msg].updateView (model updatedModel) [0x00067] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:92 at Fabulous.Core.ProgramRunner2[model,msg].processMsg (msg msg) [0x0002e] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:68
07-12 16:56:22.842 I/mono-stdout(31427): Unable to update view:: System.NullReferenceException: Object reference not set to an instance of an object.
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Platform.Android.PageRenderer.Xamarin.Forms.Platform.Android.IOrderedTraversalController.UpdateTraversalOrder () [0x000a4] in D:\a\1\sXamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:177
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].UpdateParentPageTraversalOrder () [0x00025] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:404 07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00116] in D:\a\1\sXamarin.Forms.Platform.Android\VisualElementRenderer.cs:369
07-12 16:56:22.842 I/mono-stdout(31427): at (wrapper delegate-invoke).invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\sXamarin.Forms.Core\BindableObject.cs:211
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\sXamarin.Forms.Core\Element.cs:353
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x00094] in D:\a\1\sXamarin.Forms.Core\Element.cs:210
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\sXamarin.Forms.Core\Element.cs:335
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\sXamarin.Forms.Core\VisualElement.cs:750
07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Layout1[T].OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:41 07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:464 07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:427 07-12 16:56:22.842 I/mono-stdout(31427): at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) 07-12 16:56:22.842 I/mono-stdout(31427): at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
07-12 16:56:22.842 I/mono-stdout(31427): at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object oldItem, System.Object newItem, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:354 07-12 16:56:22.842 I/mono-stdout(31427): at System.Collections.ObjectModel.ObservableCollection1[T].SetItem (System.Int32 index, T item) [0x0001c] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:210
07-12 16:56:22.842 I/mono-stdout(31427): at System.Collections.ObjectModel.Collection1[T].set_Item (System.Int32 index, T value) [0x0002b] in /Users/builder/jenkins/workspace/xamarin-android-d16-1/xamarin-android/external/mono/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:61 07-12 16:56:22.842 I/mono-stdout(31427): at Xamarin.Forms.ObservableWrapper2[TTrack,TRestrict].set_Item (System.Int32 index, TRestrict value) [0x00029] in D:\a\1\sXamarin.Forms.Core\ObservableWrapper.cs:140
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x000ec] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:407
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320
07-12 16:56:22.843 I/mono-stdout(31427): at.$Xamarin.Forms.[email protected] (Microsoft.FSharp.Core.FSharpValueOption 1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x0010e] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:411 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320 07-12 16:56:22.843 I/mono-stdout(31427): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateContentView (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentView target) [0x001c6] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:6565 07-12 16:56:22.843 I/mono-stdout(31427): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentView target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:6543
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric$cont@387[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x0010e] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:411
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, System.Collections.Generic.IList1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] update) [0x00060] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:383 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00465] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5320
07-12 16:56:22.843 I/mono-stdout(31427): at.$Xamarin.Forms.[email protected] (Microsoft.FSharp.Core.FSharpValueOption 1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:5258 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateContentPage (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00239] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12613
07-12 16:56:22.843 I/mono-stdout(31427): at.$Xamarin.Forms.[email protected] (Microsoft.FSharp.Core.FSharpValueOption 1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12585 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.Converters.updateNavigationPages (Microsoft.FSharp.Core.FSharpValueOption1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption1[T] collOpt, Xamarin.Forms.NavigationPage target, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] attach) [0x00274] in /Git/Github/Fabulous/src/Fabulous.Core/ViewConverters.fs:694
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.DynamicViews.ViewBuilders.UpdateNavigationPage (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00339] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:11975 07-12 16:56:22.843 I/mono-stdout(31427): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:11927
07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.Core.ProgramRunner2[model,msg].updateView (model updatedModel) [0x00067] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:92 07-12 16:56:22.843 I/mono-stdout(31427): at Fabulous.Core.ProgramRunner2[model,msg].processMsg (msg msg) [0x0002e] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:68
@vshapenko Do you have a sample code showcasing this issue?
Looks like, sounds like and smells like my encounter in #343.
@vshapenko Do you have a sample code showcasing this issue?
Sample code was something like this:
if(model.Flag) then View.ContentView() else View.List.View()
I have omitted all the details here as unrelated to bug.
Problem does not reproduce on emulator, and it reproduces for every such view on every device only once.
I have fixed it by drawing ListView always regardless of flag. Looks like there is a bug in ObservableCollection content comparsion. At first, we do not have any listview, only content view. At second pass, we have a listview, but do not have previous. And at third pass we memoize the list view and comparsion works as designed.
I'm getting the same issue on a Samsung S8. The emulator works perfectly fine but a debug build on the device errors with the same error. We also have an if statement that shows two completely different trees
Using Fabulous.XamarinForms 0.41 and the latest patch release for Xamarin.Forms 4.1.0.581479
This is the code that explodes. The moment Type changes from Timed to something else I get the above error.
fsharp
if model.Type = Timed then
yield View.StackLayout
(
children=[
// checkbox
View.Label(text = "Time limit (mins)")
])
yield View.Entry(text = (if model.TimeLimited then string model.Duration else String.Empty), keyboard = Keyboard.Numeric)
else
yield View.Label(text = "Number of repetitions")
yield View.Entry(text = string model.Repetitions)
Please include an entire project if you don't have repro steps
Unfortunately, @vshapenko & @marto83, I don't reproduce with the code snippets you gave.
It works fine in both the emulator and a real device (Xiaomi Redmi Note 7).
Could you write a small project where you have the issue, please?
Thanks
I will spend some time this weekend trying to isolate it and create a small project.
What complicates matters is that it works fine on some android devices.
You might want to check the device architecture. For example, #492 repros under armeabi-v7a but not x86.
Unfortunately, @vshapenko & @marto83, I don't reproduce with the code snippets you gave.
It works fine in both the emulator and a real device (Xiaomi Redmi Note 7).Could you write a small project where you have the issue, please?
Thanks
@TimLariviere for now, i can only give my thoughts on steps on repro:
Also a cause of a problem is https://github.com/fsprojects/Fabulous/blob/master/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/ViewConverters.fs#L383 I think there should be additional Option.ofObj before matching
Also ViewConverters.fs:168. Looks like there is a problem with IList parameter,which can be null
I suggest to check all the params in such functions on null because of interop
After spending days isolating #492 and #522, I am currently stuck on this bug. I hope this can be fixed soon.
This bug isn't tied to ListViews as I also hit this with AbsoluteLayout.
I think this one is related too: https://github.com/xamarin/Xamarin.Forms/pull/6415
```fs// Copyright 2018-2019 Fabulous contributors. See LICENSE.md for license.
namespace ReproApp
open System.Diagnostics
open Fabulous
open Fabulous.XamarinForms
open Xamarin.Forms
module App =
type Model =
{ Flag:bool }
type Msg =
|Flag
let initModel = {Flag=true }
let init () = initModel, Cmd.none
let update msg model =
match msg with
|Flag->{model with Flag=not model.Flag},Cmd.none
let view (model: Model) dispatch =
View.ContentPage(
content=View.Grid(
rowdefs=["auto";"*"],
children =
[
yield View.Button (text="SetFlag", command= (fun ()->dispatch Flag))
if(model.Flag) then yield (View.Label(text="Flag set")).GridRow(1)
else yield View.ListView(items=([1..100]|>List.map (fun x->View.Label(text=string x)))).GridRow(1)
]
)
)
// Note, this declaration is needed if you enable LiveUpdate
let program = Program.mkProgram init update view
type App () as app =
inherit Application ()
let runner =
App.program
|> Program.withConsoleTrace
|> XamarinFormsProgram.run app
// Uncomment this line to enable live update in debug mode.
// See https://fsprojects.github.io/Fabulous/tools.html for further instructions.
//
//do runner.EnableLiveUpdate()
// Uncomment this code to save the application state to app.Properties using Newtonsoft.Json
// See https://fsprojects.github.io/Fabulous/models.html for further instructions.
let modelId = "model"
override __.OnSleep() =
let json = Newtonsoft.Json.JsonConvert.SerializeObject(runner.CurrentModel)
Console.WriteLine("OnSleep: saving model into app.Properties, json = {0}", json)
app.Properties.[modelId] <- json
override __.OnResume() =
Console.WriteLine "OnResume: checking for model in app.Properties"
try
match app.Properties.TryGetValue modelId with
| true, (:? string as json) ->
Console.WriteLine("OnResume: restoring model from app.Properties, json = {0}", json)
let model = Newtonsoft.Json.JsonConvert.DeserializeObject<App.Model>(json)
Console.WriteLine("OnResume: restoring model from app.Properties, model = {0}", (sprintf "%0A" model))
runner.SetCurrentModel (model, Cmd.none)
| _ -> ()
with ex ->
App.program.onError("Error while restoring model found in app.Properties", ex)
override this.OnStart() =
Console.WriteLine "OnStart: using same logic as OnResume()"
this.OnResume()
```
@TimLariviere here is small repro. On my Xialomi Mi 8 throws NRE on second button click
@vshapenko Use ```fs instead of ``` to get syntax highlighting
Edit: The code block still ends with ```, so only change the start!
I can confirm that I get the same error on Samsung S8
Well, it's this time you desperately want it to crash, but it won't...
Tried it on macOS / Windows, emulator / real device (Xiaomi Redmi Note 7), asked a few people to test it with their own devices (LG G6 & Sony Xperia).
No crash.
I will try to write a UI test for it and use App Center to run the project for your devices (Samsung S8, Xiaomi Mi 8).
Hoping to produce something useful...
@SergejDK Could you also test it if you have an Android device, please?
It crashes on button click.Crash is just a record in log and there is no redraw
I tried it on my device (Motorola G6) and it works without issues.
I'll try this on some different architecure...
@vshapenko @marto83
Maybe some information is needed from you, just in case I can build the same env as you have.
Mono version
Android version
VS/VS4Mac Version
Tried it with all available architecure and different emulator but still can not reproduce....
Windows:
VS 2019 Version 16.1.6
Dotnet Core 2.2.300
On Mac all the latest...
Is there a difference at your env?
Looks like there is a bug in ObservableCollection content comparsion. At first, we do not have any listview, only content view. At second pass, we have a listview, but do not have previous. And at third pass we memoize the list view and comparsion works as designed.
@vshapenko
did you debug into Fabulous.XamarinForms and it showed null? or is that what you think?
Looks like there is a bug in ObservableCollection content comparsion. At first, we do not have any listview, only content view. At second pass, we have a listview, but do not have previous. And at third pass we memoize the list view and comparsion works as designed.
@vshapenko
did you debug into Fabulous.XamarinForms and it showed null? or is that what you think?
That is my suggestion.
The sample code given by @vshapenko doesn't show the page on my armeabi-v7a Android emulator, instead the emulator is stuck on this:

Logs
1>------ Build started: Project: NRE, Configuration: Debug Any CPU ------
1>NRE -> C:\Users\Admin\source\repos\NRE\NRE\bin\Debug\netstandard2.0\NRE.dll
2>------ Build started: Project: NRE.Android, Configuration: Debug Any CPU ------
2> "C:\Users\Admin\source\repos\NRE\.nuget\NuGet.exe" install "C:\Users\Admin\source\repos\NRE\NRE.Android\packages.config" -source "https://www.nuget.org/api/v2/" -NonInteractive -RequireConsent -solutionDir "C:\Users\Admin\source\repos\NRE"
2> Restoring NuGet packages...
2> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages'.
2> Feeds used:
2> C:\Users\Admin\.nuget\packages\
2> https://www.nuget.org/api/v2/
2> All packages listed in C:\Users\Admin\source\repos\NRE\NRE.Android\packages.config are already installed.
2> No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Runtime" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
2> NRE.Android -> C:\Users\Admin\source\repos\NRE\NRE.Android\bin\Debug\NRE.Android.dll
2> No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2> C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\javac.exe -J-Dfile.encoding=UTF8 -d obj\Debug\android\bin\classes -classpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\mono.android.jar;obj\Debug\lp\10\jl\android.arch.lifecycle.common.jar;obj\Debug\lp\11\jl\bin\classes.jar;obj\Debug\lp\12\jl\bin\classes.jar;obj\Debug\lp\13\jl\bin\classes.jar;obj\Debug\lp\15\jl\bin\classes.jar;obj\Debug\lp\16\jl\com.android.support.support-annotations.jar;obj\Debug\lp\17\jl\bin\classes.jar;obj\Debug\lp\18\jl\com.android.support.collections.jar;obj\Debug\lp\19\jl\bin\classes.jar;obj\Debug\lp\20\jl\bin\classes.jar;obj\Debug\lp\21\jl\bin\classes.jar;obj\Debug\lp\22\jl\bin\classes.jar;obj\Debug\lp\23\jl\bin\classes.jar;obj\Debug\lp\24\jl\bin\classes.jar;obj\Debug\lp\25\jl\bin\classes.jar;obj\Debug\lp\26\jl\bin\classes.jar;obj\Debug\lp\27\jl\bin\classes.jar;obj\Debug\lp\28\jl\bin\classes.jar;obj\Debug\lp\29\jl\bin\classes.jar;obj\Debug\lp\30\jl\bin\classes.jar;obj\Debug\lp\31\jl\bin\classes.jar;obj\Debug\lp\32\jl\bin\classes.jar;obj\Debug\lp\33\jl\bin\classes.jar;obj\Debug\lp\34\jl\bin\classes.jar;obj\Debug\lp\35\jl\bin\classes.jar;obj\Debug\lp\36\jl\bin\classes.jar;obj\Debug\lp\37\jl\bin\classes.jar;obj\Debug\lp\39\jl\bin\classes.jar;obj\Debug\lp\4\jl\formsviewgroup.jar;obj\Debug\lp\40\jl\bin\classes.jar;obj\Debug\lp\41\jl\bin\classes.jar;obj\Debug\lp\42\jl\bin\classes.jar;obj\Debug\lp\43\jl\bin\classes.jar;obj\Debug\lp\44\jl\bin\classes.jar;obj\Debug\lp\45\jl\bin\classes.jar;obj\Debug\lp\46\jl\bin\classes.jar;obj\Debug\lp\8\jl\android.arch.core.common.jar;obj\Debug\lp\9\jl\bin\classes.jar" -bootclasspath "C:\Program Files (x86)\Android\android-sdk\platforms\android-28\android.jar" -encoding UTF-8 "@C:\Users\Admin\AppData\Local\Temp\tmp1095.tmp"
2> C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -Dfile.encoding=UTF8 -Xmx1G -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\\lib\dx.jar" --dex --no-strict --input-list=C:\Users\Admin\AppData\Local\Temp\tmp2A68.tmp --output obj\Debug\android\bin
3>Waiting for runtime checks to complete
Detecting installed packages
Detecting installed packages...
Removing old runtime
Removing old runtime: Mono.Android.DebugRuntime...
@Happypig375
could you provide the configs of your emulator? Will try to recreate it.
That is my suggestion.
@vshapenko
allright, then I'll try something here to check this.
It's the same emulator from #492.
Xamarin 16.1.0.545 (d16-1@db7c858e8)
Xamarin Designer 16.1.0.418 (remotes/origin/d16-1@5b958bb10)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.2.112 (4db4af4)
Xamarin.Android SDK 9.3.0.23 (HEAD/d0b48056f)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: mono/mono/2018-08@3a07bd426d3
Java.Interop: xamarin/java.interop/d16-1@5ddc3e3
LibZipSharp: grendello/LibZipSharp/d16-1@44de300
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26
Xamarin.iOS and Xamarin.Mac SDK 12.10.0.157 (6bd9475)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Mono version: 5.20.1 (by mono --version)
I meant sth. like this:

(not my current setup....)
Because if I just create a armeabi-v7a it still works. It is slow but it works. So mybe my configurations of the emulator is different.
Thanks for the information @vshapenko
Will look at it later today!

@TimLariviere @SergejDK
Runs fine on redmi 4x and Nokia 8
Looks like it crashes on certain CPUs.
@TimLariviere @SergejDK @Happypig375
Small update. I have found a workaround. Following code works fine:
```fs let view (model: Model) dispatch =
View.ContentPage(
content=View.Grid(
rowdefs=["auto";"*"],
children =
[
yield View.Button (text="SetFlag", command= (fun ()->dispatch Flag))
yield View.Label(text="Flag set",isVisible=(model.Flag)).GridRow(1)
yield View.ListView(items=([1..100]|>List.map (fun x->View.Label(text=string x))),isVisible=not model.Flag).GridRow(1)
]
)
)
```
Based on this, it looks like there are some issues with visual tree state if it is changed per same view. I think the safe way is to have whole visual tree all the time, and hide elements we do not need
Update : my main app still not working...
Additional info.
I am also getting following exception:
Unable to update view:: System.InvalidCastException: Specified cast is not valid.
07-19 12:58:52.953 I/mono-stdout(27246): at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
07-19 12:58:52.953 I/mono-stdout(27246): at Microsoft.FSharp.Core.LanguagePrimitives+IntrinsicFunctions.UnboxGeneric[T] (System.Object source) [0x00006] in <5c64a998dff9fae1a745038398a9645c>:0
07-19 12:58:52.953 I/mono-stdout(27246): at <StartupCode$Fabulous>.$ViewElement+Create@46-1[T].Invoke (Microsoft.FSharp.Core.FSharpValueOption`1[T] prev, Fabulous.ViewElement curr, System.Object target) [0x00000] in D:\a\1\s\src\Fabulous\ViewElement.fs:46
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.ViewElement.UpdateIncremental (Fabulous.ViewElement prev, System.Object target) [0x00000] in D:\a\1\s\src\Fabulous\ViewElement.fs:85
07-19 12:58:52.953 I/mono-stdout(27246): at <StartupCode$Fabulous-XamarinForms>[email protected] (Fabulous.ViewElement prevChild, Fabulous.ViewElement newChild, Xamarin.Forms.View targetChild) [0x00000] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:5365
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.Converters.updateCollectionGeneric$cont@148[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevCollOpt, System.Collections.Generic.IList`1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] update, T[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x0010e] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms.Core\ViewConverters.fs:172
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.Converters.updateCollectionGeneric[T,TargetT] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption`1[T] collOpt, System.Collections.Generic.IList`1[T] targetColl, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] create, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] attach, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] canReuse, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] update) [0x00060] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms.Core\ViewConverters.fs:144
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.ViewBuilders.UpdateGrid (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.Grid target) [0x00460] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:5328
07-19 12:58:52.953 I/mono-stdout(27246): at <StartupCode$Fabulous-XamarinForms>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.Grid target) [0x00000] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:5266
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.ViewElement.UpdateIncremental (Fabulous.ViewElement prev, System.Object target) [0x00000] in D:\a\1\s\src\Fabulous\ViewElement.fs:85
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.ViewBuilders.UpdateContentPage (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00234] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:12621
07-19 12:58:52.953 I/mono-stdout(27246): at <StartupCode$Fabulous-XamarinForms>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00000] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:12593
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.ViewElement.UpdateIncremental (Fabulous.ViewElement prev, System.Object target) [0x00000] in D:\a\1\s\src\Fabulous\ViewElement.fs:85
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.Converters.updateNavigationPages$cont@422 (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevCollOpt, Xamarin.Forms.NavigationPage target, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] attach, Fabulous.ViewElement[] coll, Microsoft.FSharp.Core.Unit unitVar) [0x00210] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms.Core\ViewConverters.fs:455
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.Converters.updateNavigationPages (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevCollOpt, Microsoft.FSharp.Core.FSharpValueOption`1[T] collOpt, Xamarin.Forms.NavigationPage target, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] attach) [0x00062] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms.Core\ViewConverters.fs:418
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.XamarinForms.ViewBuilders.UpdateNavigationPage (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00334] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:11983
07-19 12:58:52.953 I/mono-stdout(27246): at <StartupCode$Fabulous-XamarinForms>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.ViewElement curr, Xamarin.Forms.NavigationPage target) [0x00000] in D:\a\1\s\Fabulous.XamarinForms\src\Fabulous.XamarinForms\Xamarin.Forms.Core.fs:11935
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.ProgramRunner`3[arg,model,msg].updateView (model updatedModel) [0x00072] in D:\a\1\s\src\Fabulous\Program.fs:91
07-19 12:58:52.953 I/mono-stdout(27246): at Fabulous.ProgramRunner`3[arg,model,msg].processMsg (msg msg) [0x0002e] in D:\a\1\s\src\Fabulous\Program.fs:66
Got my main app to work with fix provided above plus disabling skiasharp control on page
@Happypig375
I use the same emulator.....
@vshapenko
the versions looking good to me. using the same stuff.....
I'll try to find a phone where the NRE is happening...
Sorry for the bug....
@vshapenko
Your example created the error from #492 which @Happypig375 discovered on antoher device (Motorola G6) maybe your issue and the one from @Happypig375 are related.
Will try to identify what is happenend here that makes this stuff go crazy.
@SergejDK i would like to help, but for now i do not have much knowledge about fabulous internals.
@vshapenko
do you have VS 2017 installed or only 2019?
@SergejDK only vs 2019, but also rider
Even something as simple as
open Fabulous.Core
open Fabulous.DynamicViews
open Xamarin.Forms
module App =
let program = Program.mkSimple id (fun () -> id) (fun _ _ -> View.ContentPage(View.Button "Hi~"))
type App () as app =
inherit Application ()
let runner =
App.program
|> Program.withErrorHandler (fun (msg, exn) -> System.Diagnostics.Debug.WriteLine exn
System.Diagnostics.Debugger.Break())
|> Program.runWithDynamicView app
Throws an NRE on startup on my Xiaomi Redmi 6. The emulators cannot reproduce this.
@vshapenko @Happypig375 Does it crash the same when deploying in Debug and Release?
@Happypig375 Do you have a stack trace for your last repro?
The initial stack trace was about the ListView, but you don't have any in your repro.
I tried with Debug, throws NRE when debugger attached, runs fine when not attached
Runs fine with Release
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
07-24 18:22:04.798 D/Mono (31898): DllImport attempting to load: '/system/lib/liblog.so'.
07-24 18:22:04.799 D/Mono (31898): DllImport loaded library '/system/lib/liblog.so'.
07-24 18:22:04.799 D/Mono (31898): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
07-24 18:22:04.799 D/Mono (31898): Searching for '__android_log_print'.
07-24 18:22:04.799 D/Mono (31898): Probing '__android_log_print'.
07-24 18:22:04.799 D/Mono (31898): Found as '__android_log_print'.
07-24 18:22:04.810 I/MonoDroid(31898): UNHANDLED EXCEPTION:
07-24 18:22:04.821 I/MonoDroid(31898): System.NullReferenceException: Object reference not set to an instance of an object
07-24 18:22:04.821 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewBuilders.UpdateNavigableElement (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigableElement target) [0x000e5] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:708
07-24 18:22:04.821 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewBuilders.UpdateFuncNavigableElement@ (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigableElement target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:698
07-24 18:22:04.821 I/MonoDroid(31898): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.NavigableElement target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:697
07-24 18:22:04.821 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewBuilders.UpdateVisualElement (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.VisualElement target) [0x00044] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:892
07-24 18:22:04.822 I/MonoDroid(31898): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.VisualElement target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:886
07-24 18:22:04.822 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewBuilders.UpdatePage (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Page target) [0x00044] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:11312
07-24 18:22:04.822 I/MonoDroid(31898): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.Page target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:11306
07-24 18:22:04.822 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewBuilders.UpdateContentPage (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00044] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12591
07-24 18:22:04.822 I/MonoDroid(31898): at <StartupCode$Fabulous-Core>[email protected] (Microsoft.FSharp.Core.FSharpValueOption`1[T] prevOpt, Fabulous.DynamicViews.ViewElement curr, Xamarin.Forms.ContentPage target) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/Xamarin.Forms.Core.fs:12585
07-24 18:22:04.822 I/MonoDroid(31898): at Fabulous.DynamicViews.ViewElement.Create () [0x0000d] in /Git/Github/Fabulous/src/Fabulous.Core/ViewElement.fs:95
07-24 18:22:04.822 I/MonoDroid(31898): at Fabulous.Core.ProgramRunner`2[model,msg]..ctor (Xamarin.Forms.Application app, Fabulous.Core.Program`3[model,msg,view] program) [0x0007a] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:53
07-24 18:22:04.822 I/MonoDroid(31898): at Fabulous.Core.ProgramModule.runWithDynamicView[model,msg] (Xamarin.Forms.Application app, Fabulous.Core.Program`3[model,msg,view] program) [0x00000] in /Git/Github/Fabulous/src/Fabulous.Core/ElmishProgram.fs:241
07-24 18:22:04.822 I/MonoDroid(31898): at PanaIoTApp.App..ctor () [0x00016] in C:\Users\Admin\source\repos\Panasonic IoT App\PanaIoTApp\PanaIoTApp.fs:13
07-24 18:22:04.823 I/MonoDroid(31898): at PanaIoTApp.Android.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0002e] in C:\Users\Admin\source\repos\Panasonic IoT App\PanaIoTApp.Android\MainActivity.fs:28
07-24 18:22:04.823 I/MonoDroid(31898): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <ff9f3f3d4e134974a889db1b532c9b6e>:0
07-24 18:22:04.823 I/MonoDroid(31898): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)
07-24 18:22:04.842 W/zygote (31898): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
07-24 18:22:04.846 D/Mono (31898): DllImport searching in: '__Internal' ('(null)').
07-24 18:22:04.846 D/Mono (31898): Searching for 'java_interop_jnienv_throw'.
07-24 18:22:04.846 D/Mono (31898): Probing 'java_interop_jnienv_throw'.
07-24 18:22:04.846 D/Mono (31898): Found as 'java_interop_jnienv_throw'.
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
@Happypig375 Would you happen to have the solution of Fabulous on your machine where you debug your device?
If yes, could you try to replace the code of the Calculator sample with yours and debug on your device.
And then, can you try to find the specific line where the null appears?
Sorry for asking you that, but I can't reproduce myself.
I think its https://github.com/fsprojects/Fabulous/issues/343#issuecomment-507599708 all over again
@vshapenko @Happypig375 Does it crash the same when deploying in Debug and Release?
My sample crashes on release same manner as debug. I am currently trying to locate the source of problem by debugging fabulous sources. Something goes really wrong at ViewConverters.fs:168. Looks like maybe we first should collect all the changes and then update targetColl.
@TimLariviere @SergejDK
Can the following methods be the source of our problems in case XF extensively uses Observable collections?:
```fs
/// Convert a sequence to an array, maintaining the object identity of arrays
let seqToArray (itemsSource:seq<'T>) =
match itemsSource with
| :? ('T []) as arr -> arr
| es -> Array.ofSeq es
/// Convert a sequence to an IList, maintaining the object identity of any IList
let seqToIListUntyped (itemsSource:seq<'T>) =
match itemsSource with
| :? System.Collections.IList as arr -> arr
| es -> (Array.ofSeq es :> System.Collections.IList) ```
Another repro:
namespace NRERepro
open Fabulous
open Fabulous.XamarinForms
open Xamarin.Forms
module App =
type Model = A | B
type Msg = OpenB
let init () = A, Cmd.ofMsg OpenB
let update OpenB model = B, Cmd.none
let view model dispatch =
match model with A -> View.BoxView Color.Green | B -> View.Button "B"
// Removing does not affect bug, purely for visibility
|> layoutBounds (Rectangle(0., 0., 1., 1.))
|> layoutFlags AbsoluteLayoutFlags.All
|> List.singleton
|> fun x -> View.AbsoluteLayout x
|> fun x -> View.ContentPage x
// Note, this declaration is needed if you enable LiveUpdate
let program = Program.mkProgram init update view
type App () as app =
inherit Application ()
let runner = App.program |> XamarinFormsProgram.run app
Only NRE on devices such as Xiaomi Redmi 6, not reproducible on Emulator.
Config: Debug or Release, both can repro
CtrlF5 was used to avoid #492.
```
android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.PageRenderer.Xamarin.Forms.Platform.Android.IOrderedTraversalController.UpdateTraversalOrder () [0x000ea] in
at Xamarin.Forms.Platform.Android.PageRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00013] in
at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4) [0x00008] in <662026c9033c41d3890f3b3e3eae3fde>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.34(intptr,intptr,bool,int,int,int,int)
--- End of stack trace from previous location where exception was thrown ---
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
at Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout (System.Int32 p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4, System.Int32 p5) [0x00090] in <662026c9033c41d3890f3b3e3eae3fde>:0
at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout () [0x00163] in
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].UpdateLayout () [0x0001c] in
at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0002b] in
at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00025] in
at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00009] in
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr,bool,int,int,int,int)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_onLayout(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.onLayout(PlatformRenderer.java:63)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:765)
at android.view.View.layout(View.java:19828)
at android.view.ViewGroup.layout(ViewGroup.java:6154)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2641)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2346)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1482)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7122)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:983)
at android.view.Choreographer.doCallbacks(Choreographer.java:795)
at android.view.Choreographer.doFrame(Choreographer.java:723)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:969)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
@TimLariviere may we somehow "defer" visual tree update until we fully done? Looks like working with ObservableCollection itself (casted to IList) may produce some, hmmm... undesirable effects on some platforms. I think this can be the case of this issue. We update visual tree in "real-time" and at some point it becomes incosistent, and XF just does not know, what to do
@TimLariviere @SergejDK I have found a workaround. Looks like we should use
``` fs
targetColl.RemoveAt i
targetColl.Insert(i,targetChild)
instead of
```fs
targetColl.[i]<-targetChild
at ViewConverters.fs:170
@Happypig375
could you try @vshapenko workaround?
Currently dont have the phone where I could reproduce....
With VS 16.1.6,
* * * * * * * * * * * * * * * *
Build fingerprint: 'xiaomi/cereus/cereus:8.1.0/O11019/V10.2.2.0.OCGMIXM:user/release-keys'
Revision: '0'
ABI: 'arm'
pid: 8439, tid: 8439, name: com.companyname >>> com.companyname <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1
Cause: null pointer dereference
r0 00000000 r1 80000000 r2 00000001 r3 0000002c
r4 bee40be8 r5 00000001 r6 bee40be8 r7 8ce5a6b8
r8 00000021 r9 a5abeb00 sl 00000000 fp bee40be0
ip 93528dc4 sp bee40bd0 lr 93277be4 pc 93277c24 cpsr 600e0010
backtrace:
#00 pc 000d3c24 /data/app/Mono.Android.DebugRuntime-8v168zkE6Zm9Kaq2iotbxA==/lib/arm/libmonosgen-32bit-2.0.so
without debugger.
Both crashes are fixed by #531, only without debugger. With debugger, https://github.com/fsprojects/Fabulous/issues/343#issuecomment-507599708 still persists.
However, another NRE has occurred which was not fixed by #531. The exception source is also https://github.com/fsprojects/Fabulous/issues/343#issuecomment-507599708.
Edit: This should be
Both crashes are fixed by #531, only without debugger. With debugger, #343 (comment) still persists.
Is it just me or VS16.2.0 just fixed this bug?
@Happypig375 Which specific bug do you mean?
I'll test further to see which are fixed.
I created 2 new clean issues to help track those mentioned here.
See #535 and #536
I'm closing this one to keep it as a reference.
And we will continue on the other issues.
If I missed any other issue or repro/stack trace, don't hesitate to tell me.
Most helpful comment
@vshapenko
Your example created the error from #492 which @Happypig375 discovered on antoher device (Motorola G6) maybe your issue and the one from @Happypig375 are related.
Will try to identify what is happenend here that makes this stuff go crazy.