Open mruncola opened 4 months ago
This seems to be a problem on Android, too.
System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Maui.Controls.Handlers.Items.ItemContentView.OnMeasure(Int32 widthMeasureSpec, Int32 heightMeasureSpec)
at Android.Views.View.n_OnMeasure_II(IntPtr jnienv, IntPtr native__this, Int32 widthMeasureSpec, Int32 heightMeasureSpec)
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPII_V(_JniMarshal_PPII_V callback, IntPtr jnienv, IntPtr klazz, Int32 p0, Int32 p1)
Java.Lang.IllegalStateException: View with id -1: crc645d80431ce5f73f11.ItemContentView#onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at Java.Interop.JniEnvironment.StaticMethods.CallStaticLongMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)
at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeInt64Method(String encodedMember, JniArgumentValue* parameters)
at Microsoft.Maui.PlatformInterop.MeasureAndGetWidthAndHeight(View view, Int32 widthMeasureSpec, Int32 heightMeasureSpec)
at Microsoft.Maui.ViewHandlerExtensions.GetDesiredSizeFromHandler(IViewHandler viewHandler, Double widthConstraint, Double heightConstraint)
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.RecyclerView.Widget.RecyclerView, Xamarin.AndroidX.RecyclerView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetDesiredSize(Double widthConstraint, Double heightConstraint)
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewHandler`1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetDesiredSize(Double widthConstraint, Double heightConstraint)
at Microsoft.Maui.Layouts.LayoutExtensions.ComputeDesiredSize(IView view, Double widthConstraint, Double heightConstraint)
at Microsoft.Maui.Controls.VisualElement.MeasureOverride(Double widthConstraint, Double heightConstraint)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Measure(Double widthConstraint, Double heightConstraint)
at DevExpress.Maui.Core.Internal.DXViewContainer.OnMeasure(Int32 widthMeasureSpec, Int32 heightMeasureSpec)
at Android.Views.View.n_OnMeasure_II(IntPtr jnienv, IntPtr native__this, Int32 widthMeasureSpec, Int32 heightMeasureSpec)
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPII_V(_JniMarshal_PPII_V callback, IntPtr jnienv, IntPtr klazz, Int32 p0, Int32 p1)
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: View with id -1: crc645d80431ce5f73f11.ItemContentView#onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:22083)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:10124)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1688)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4604)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3981)
at android.view.View.measure(View.java:22071)
at com.microsoft.maui.PlatformInterop.measureAndGetWidthAndHeight(PlatformInterop.java:403)
at crc647a19118a24842bb1.DXViewContainer.n_onMeasure(Native Method)
at crc647a19118a24842bb1.DXViewContainer.onMeasure(DXViewContainer.java:58)
at android.view.View.measure(View.java:22071)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1638)
at android.view.View.measure(View.java:22071)
at com.devexpress.navigation.PagerControl.onMeasure(PagerControl.java:161)
at android.view.View.measure(View.java:22071)
at com.devexpress.navigation.TabControl.onMeasureCore(TabControl.java:352)
at com.devexpress.dxcore.DXNativeView.onMeasure(DXNativeView.kt:36)
at android.view.View.measure(View.java:22071)
at com.microsoft.maui.PlatformInterop.measureAndGetWidthAndHeight(PlatformInterop.java:403)
at crc6452ffdc5b34af3a0f.LayoutViewGroup.n_onMeasure(Native Method)
at crc6452ffdc5b34af3a0f.LayoutViewGroup.onMeasure(LayoutViewGroup.java:59)
at android.view.View.measure(View.java:22071)
at com.microsoft.maui.PlatformInterop.measureAndGetWidthAndHeight(PlatformInterop.java:403)
at crc6452ffdc5b34af3a0f.ContentViewGroup.n_onMeasure(Native Method)
at crc6452ffdc5b34af3a0f.ContentViewGroup.onMeasure(ContentViewGroup.java:59)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:795)
at com.google.android.material.appbar.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:100)
at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:2376)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:866)
at android.view.View.measure(View.java:22071)
at crc64338477404e88479c.ModalNavigationManager_ModalContainer.n_onMeasure(Native Method)
at crc64338477404e88479c.ModalNavigationManager_ModalContainer.onMeasure(ModalNavigationManager_ModalContainer.java:85)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
at android.view.View.measure(View.java:22071)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2422)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1504)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
@cytoph this looks like a different issue.
I set up a minimal sample that is pretty close to my real application. It seemed like it worked in the sample app that it would wait for the pop before executing the tear down. However if you look at this it is tearing down my "equipmentlistpage" once it arrives on "equipmentdetailpage".
Reproduction Repo: https://github.com/mruncola/DotnetMauiMemoryCrash
I added a toggle to change the navigation mechanism under the hood to use goto and push pop so you can see they both have similar results.
Push / Pop ----
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ElementForViewController(UIViewController viewController) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.NavDelegate.WillShowViewController(UINavigationController navigationController, UIViewController viewController, Boolean animated) --- End of stack trace from previous location --- at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SadMemory.Program.Main(String[] args) in /DotnetMauiMemoryCrash/SadMemory/Platforms/iOS/Program.cs:line 13 2024-04-23 15:28:21.657004-0400 SadMemory[37997:4033394] Unhandled managed exception: Object reference not set to an instance of an object. (System.NullReferenceException) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ElementForViewController(UIViewController viewController) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.NavDelegate.WillShowViewController(UINavigationController navigationController, UIViewController viewController, Boolean animated) --- End of stack trace from previous location --- at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SadMemory.Program.Main(String[] args) in /DotnetMauiMemoryCrash/SadMemory/Platforms/iOS/Program.cs:line 13
GoTo ----
2024-04-23 15:09:51.402746-0400 SadMemory[36835:4004936] Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ElementForViewController(UIViewController viewController) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.NavDelegate.WillShowViewController(UINavigationController navigationController, UIViewController viewController, Boolean animated) --- End of stack trace from previous location --- at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SadMemory.Program.Main(String[] args) in /DotnetMauiMemoryCrash/SadMemory/Platforms/iOS/Program.cs:line 13 2024-04-23 15:09:51.403406-0400 SadMemory[36835:4004936] Unhandled managed exception: Object reference not set to an instance of an object. (System.NullReferenceException) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.ElementForViewController(UIViewController viewController) at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.NavDelegate.WillShowViewController(UINavigationController navigationController, UIViewController viewController, Boolean animated) --- End of stack trace from previous location --- at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SadMemory.Program.Main(String[] args) in /DotnetMauiMemoryCrash/SadMemory/Platforms/iOS/Program.cs:line 13