question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null Reference Exception thrown when updating views

See original GitHub issue

Original issue: #518

While updating the UI when switching between 2 different contents (Label -> ListView), the app throws a NullReferenceException (coming from Xamarin.Forms) but only on some Android devices.

  • Affected platforms: Android
  • Affected build mode: Debug, Release
  • Affected devices:
    • Xiaomi Mi 8
    • Samsung S8
  • Unaffected devices:
    • Emulators
    • Xiaomi Redmi Note 7
    • LG G6
    • Google Nexus 5
    • Sony Xperia
    • Motorola G6
    • Xiaomi Redmi 4X
    • Nokia 8

Stack trace

Stack trace for Repro 1
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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.Forms.Core
BindableObject.cs:211
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x00094] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:210
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:335
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.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\s\Xamarin.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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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>.$Xamarin.Forms.Core+get_UpdateFuncContentView@6543.Invoke (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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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.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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncContentPage@12585.Invoke (Microsoft.FSharp.Core.FSharpValueOption1[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>.$Xamarin.Forms.Core+get_UpdateFuncNavigationPage@11927.Invoke (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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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\s\Xamarin.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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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.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>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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>.$Xamarin.Forms.Core+get_UpdateFuncContentView@6543.Invoke (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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncGrid@5258.Invoke (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.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 <StartupCode$Fabulous-Core>.$Xamarin.Forms.Core+get_UpdateFuncContentPage@12585.Invoke (Microsoft.FSharp.Core.FSharpValueOption1[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>.$Xamarin.Forms.Core+get_UpdateFuncNavigationPage@11927.Invoke (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
Stack trace for Repro 2
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 <d498db4cf6c940a09b62e9279681494b>:0 
  at Xamarin.Forms.Platform.Android.PageRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00013] in <d498db4cf6c940a09b62e9279681494b>:0 
  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 <d498db4cf6c940a09b62e9279681494b>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].UpdateLayout () [0x0001c] in <d498db4cf6c940a09b62e9279681494b>:0 
  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 <d498db4cf6c940a09b62e9279681494b>:0 
  at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00025] in <d498db4cf6c940a09b62e9279681494b>:0 
  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 <ff9f3f3d4e134974a889db1b532c9b6e>:0 
  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)

Repro

Repro 1

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
#if DEBUG
        |> Program.withConsoleTrace
#endif
        |> XamarinFormsProgram.run app

Repro 2

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Happypig375commented, Aug 2, 2019

I’m creating an issue for Xamarin.Forms.

0reactions
TimLarivierecommented, Feb 10, 2020

Closing since it has been fixed in XF 4.3 and F.XF already supports it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Updating database using entity framework throws Null ...
Firstly, When a user selects a row from the data grid, I want that specific row to update.
Read more >
NullReferenceException Class (System)
The exception that is thrown when there is an attempt to dereference a null object reference.
Read more >
Null Reference exception thrown by debugger
When running a debug session on a target android phone a Null Reference exception message is thrown on a screen where visual elements'...
Read more >
Null Reference Exceptions
Null Reference Exceptions. A NullReferenceException happens when you try to access a reference variable that isn't referencing any object.
Read more >
Fix Null Reference Exception in Unity - YouTube
I then try to get the tag of that variable but because the object is null it throws the Null Reference Exception. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found