Random rare crashing after navigated to page

Joseph_RaduJoseph_Radu ✭✭Member ✭✭

Crash started happening over 2 weeks ago. I have been unable to replicate the crash myself but see that it will occur 2-6 times a day under no unusual circumstance.

JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) Drawable.CopyBounds (Android.Graphics.Rect bounds) ButtonLayoutManager.OnLayout (System.Boolean changed, System.Int32 left, System.Int32 top, System.Int32 right, System.Int32 bottom) ButtonRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) View.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 left, System.Int32 top, System.Int32 right, System.Int32 bottom) (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.108(intptr,intptr,bool,int,int,int,int) java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Rect.set(android.graphics.Rect)' on a null object reference android.graphics.drawable.Drawable.copyBounds(Drawable.java:238) md5f92e0daf340890c9667469657ee2ece8.ButtonRenderer.n_onLayout(Native Method) md5f92e0daf340890c9667469657ee2ece8.ButtonRenderer.onLayout(ButtonRenderer.java:63) android.view.View.layout(View.java:17641) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:81) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md51558244f76c53b6aeda52c8a337f2c37.ListViewAdapter.n_getView(Native Method) md51558244f76c53b6aeda52c8a337f2c37.ListViewAdapter.getView(ListViewAdapter.java:100) android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220) android.widget.AbsListView.obtainView(AbsListView.java:2378) android.widget.ListView.makeAndAddView(ListView.java:1970) android.widget.ListView.fillDown(ListView.java:704) android.widget.ListView.fillSpecific(ListView.java:1412) android.widget.ListView.layoutChildren(ListView.java:1708) android.widget.AbsListView.onLayout(AbsListView.java:2170) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:611) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) md51558244f76c53b6aeda52c8a337f2c37.ListViewRenderer.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.ListViewRenderer.onLayout(ListViewRenderer.java:65) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:81) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:81) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md51558244f76c53b6aeda52c8a337f2c37.PageRenderer.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.PageRenderer.onLayout(PageRenderer.java:72) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.n_onLayout(Native Method) md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:65) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37) md58432a647068b097f9637064b8985a5e0.Platform_ModalContainer.n_onLayout(Native Method) md58432a647068b097f9637064b8985a5e0.Platform_ModalContainer.onLayout(Platform_ModalContainer.java:45) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.n_onLayout(Native Method) md51558244f76c53b6aeda52c8a337f2c37.PlatformRenderer.onLayout(PlatformRenderer.java:55) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) android.widget.FrameLayout.onLayout(FrameLayout.java:261) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) android.widget.FrameLayout.onLayout(FrameLayout.java:261) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) android.widget.FrameLayout.onLayout(FrameLayout.java:261) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) android.widget.LinearLayout.onLayout(LinearLayout.java:1494) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) android.widget.FrameLayout.onLayout(FrameLayout.java:261) com.android.internal.policy.DecorView.onLayout(DecorView.java:727) android.view.View.layout(View.java:17641) android.view.ViewGroup.layout(ViewGroup.java:5575) android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2351) android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2073) android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1259) android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6579) android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) android.view.Choreographer.doCallbacks(Choreographer.java:686) android.view.Choreographer.doFrame(Choreographer.java:621) android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) android.os.Handler.handleCallback(Handler.java:751) android.os.Handler.dispatchMessage(Handler.java:95) android.os.Looper.loop(Looper.java:154) android.app.ActivityThread.main(ActivityThread.java:6121) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

Best Answer

  • Joseph_RaduJoseph_Radu ✭✭ ✭✭
    Accepted Answer

    The crashing appeared to revolve around my ObservableCollection list which was being binded to a listview. Frequently the list was being cleared and new items frequently added, rarely crashing after an item was added. There was no sign of any issues around null values (which didn't exist in any item).

Answers

  • jezhjezh Xamurai Member, Xamarin Team Xamurai

    We can see the following log from your post log.

    Android.Runtime.DynamicMethodNameCounter.108(intptr,intptr,bool,int,int,int,int) java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Rect.set(android.graphics.Rect)' on a null object reference android.graphics.drawable.Drawable.copyBounds(Drawable.java:238) 
    

    So ,there should be some code that you set value to a null object reference .
    Mean while according the log you post, you can pay special attention to where the layout is loaded.Especially the code involves log-related loading layouts.
    For example, layout in HeaderViewListAdapter,etc.

  • Joseph_RaduJoseph_Radu ✭✭ Member ✭✭
    edited July 12

    I'm wondering if the crash is from a binding I have in a listview. Could it be caused by my ListView.GroupHeaderTemplate?

    <ListView x:Name="DeliveryItemList" ItemsSource="{Binding GroupedDeliveryItems}" GroupDisplayBinding="{Binding ReferenceNumber}" SelectedItem="{Binding SelectedDeliveryItem, Mode=TwoWay}" IsGroupingEnabled="True" HasUnevenRows="True" SeparatorColor="{StaticResource ColorLightestGray}"> <ListView.GroupHeaderTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal" Padding="4,2" BackgroundColor="{StaticResource ColorWhite}"> <Label Style="{StaticResource Label_Foot}" Text="Ref"/> <Label Style="{StaticResource Label_List}" FontSize="20" Text="{Binding ReferenceNumberHeader}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.GroupHeaderTemplate>

  • jezhjezh Xamurai Member, Xamarin Team Xamurai
    edited July 12

    I'm just making an assumption based on your log trace, and it's depending the code of your app.

    You need to analyze your code according to the log trace.

  • Joseph_RaduJoseph_Radu ✭✭ Member ✭✭
    Accepted Answer

    The crashing appeared to revolve around my ObservableCollection list which was being binded to a listview. Frequently the list was being cleared and new items frequently added, rarely crashing after an item was added. There was no sign of any issues around null values (which didn't exist in any item).

  • heuvelheuvel Member

    I have the same issue. Did you find an acceptable work-around for the problem?

  • freezfreez Member

    I also have this issue, the error appears randomly. :'(
    What is causing this error? Does anyone know a solution?

  • Joseph_RaduJoseph_Radu ✭✭ Member ✭✭

    @freez @heuvel The crashing stopped after I had switched from
    ObservableCollection.Clear()
    to
    while (ObservableCollection.Any()) { ObservableCollection.RemoveAt(0); }

  • MatteoPiccioniMatteoPiccioni ✭✭ USMember ✭✭
    edited October 7

    I have the same problem too.
    Unfortunately I dont use .Clear() on ObservableCollection...

    I only have coll.Add(x), coll.RemoveAt(y) and I only modify the property of item inside ObservableCollection
    In my opinion this is a but introduced with X.F. 4.1

  • RobHouweling.4203RobHouweling.4203 ✭✭ USMember ✭✭

    @MatteoPiccioni said:
    I have the same problem too.
    Unfortunately I dont use .Clear() on ObservableCollection...

    I only have coll.Add(x), coll.RemoveAt(y) and I only modify the property of item inside ObservableCollection
    In my opinion this is a but introduced with X.F. 4.1

    Have you filed a bug on Github?

  • MatteoPiccioniMatteoPiccioni ✭✭ USMember ✭✭

    @RobHouweling.4203 said:

    @MatteoPiccioni said:
    I have the same problem too.
    Unfortunately I dont use .Clear() on ObservableCollection...

    I only have coll.Add(x), coll.RemoveAt(y) and I only modify the property of item inside ObservableCollection
    In my opinion this is a but introduced with X.F. 4.1

    Have you filed a bug on Github?

    Not yet..
    Its difficult to create a sample project :neutral:
    Anyway I'll fill a bug as soon as possible

Sign In or Register to comment.