Bug 40030 - Xamarin forms App crashing randomly in Android
Summary: Xamarin forms App crashing randomly in Android
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.0.1
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-31 21:10 UTC by Lavanya Kumari
Modified: 2017-04-16 12:37 UTC (History)
5 users (show)

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


Attachments
Xamarin app crash issue (4.01 KB, application/zip)
2016-03-31 22:30 UTC, Lavanya Kumari
Details
Source Code with Android Project (21.29 KB, application/zip)
2016-03-31 23:11 UTC, Lavanya Kumari
Details


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

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Lavanya Kumari 2016-03-31 21:10:35 UTC
Our Xamarin Forms app is inconsistently crashing on Android devices. Most of the times it works fine, but it crashes randomly on android devices in a specific scenario. 

Here is the stack trace of the exception:

System.ArgumentException'jobject' must not be IntPtr.Zero. Parameter name: jobject
Android.Runtime.JNIEnv.CallVoidMethod(IntPtr jobject, IntPtr jmethod, JValue* parms)
Android.Widget.TextView.set_TextFormatted(ICharSequence value)
Android.Widget.TextView.set_Text(string value)
Xamarin.Forms.Platform.Android.LabelRenderer.UpdateText()
Xamarin.Forms.Platform.Android.LabelRenderer.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
<Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent)
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)
Xamarin.Forms.BindingExpression.Apply(object sourceObject, BindableObject target, BindableProperty property)
Xamarin.Forms.Binding.Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty)
Xamarin.Forms.BindableObject.ApplyBindings(object oldContext, bool skipBindingContext)
Xamarin.Forms.BindableObject.ApplyBindings(object oldContext)
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)
Xamarin.Forms.Element.OnBindingContextChanged()
Xamarin.Forms.View.OnBindingContextChanged()
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)
Xamarin.Forms.Element.OnBindingContextChanged()
Xamarin.Forms.Cell.OnBindingContextChanged()
Xamarin.Forms.BindableObject.BindingContextPropertyBindingPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent)
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value)
Xamarin.Forms.BindableObject.set_BindingContext(object value)
Xamarin.Forms.TemplatedItemsList<TView, TItem>.<UnhookItem>d__119.MoveNext()
Android.App.SyncContext.<Post>c__AnonStorey0.<>m__0()
Java.Lang.Thread.RunnableImplementor.Run()
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)
at (wrapper dynamic-method) System.Object:4e2b30d8-f6ce-476c-a8e5-553cdb35ffb8 (intptr,intptr)

iOS app is very stable and it never crashes. Also, Android app is not crashing in emulators. It’s only crashing in Devices.

We are using a common View Model for two content pages. The page where app crashes is having a Grouped Listview of items and item source binding is with a common view model that we are using for two separate pages.

Is this issue similar to this issue: https://bugzilla.xamarin.com/show_bug.cgi?id=24286

Attached is the test project.
Comment 1 Lavanya Kumari 2016-03-31 22:30:51 UTC
Created attachment 15574 [details]
Xamarin app crash issue
Comment 2 Lavanya Kumari 2016-03-31 23:11:05 UTC
Created attachment 15577 [details]
Source Code with Android Project
Comment 3 Lavanya Kumari 2016-03-31 23:15:40 UTC
Hi,

Here are the steps to replicate the issue:
1. Upon application launch, click on "Call Doctor" button in bottom of page.
2. Come back to app screen from the dialer.
3. Click on the text that says "Click here to Open Details of your risk".

Expected Result:
It should display a grouped Listview containing two hard coded lists.

Actual Result:
Application crashes. The crash is not always occurring, it is inconsistent.
Comment 4 E.Z. Hart [MSFT] 2016-04-05 17:33:53 UTC
The repro project you submitted is using version 1.3.5.6335 of Xamarin Forms - does this problem still occur on newer versions? Also, could you let us know which device models you're seeing this issue on? 

Thank you,
The XF Team
Comment 5 Lavanya Kumari 2016-04-21 15:22:44 UTC
Hi, 

Yes, it happens in newer versions also. Now, we are using Version 2.0.1.6495.

The device models where application crashes are - Samsung Note4 and Motorola MotoX. 

Thank you,
Lavanya
Comment 6 Paul DiPietro [MSFT] 2016-05-04 16:48:44 UTC
I'm currently unable to reproduce this crash on both an emulator and a Galaxy S5 device using the latest 2.2 stable using the project and steps provided, repeated a number of times on both the aforementioned emulator and device. Before closing this I would like to see if you're still experiencing the problem on your specific devices on the latest stable version, and if so, what the level of frequency is following those steps you outlined prior.
Comment 7 Lavanya Kumari 2016-06-07 20:47:45 UTC
Yes, this issue is not occurring in latest 2.2. Thanks!
Comment 8 Haka 2017-04-16 12:37:29 UTC
Dear Paul DiPietro,

i have the same issue with same device crashing.
I asked the question before without an answer 
https://bugzilla.xamarin.com/show_bug.cgi?id=54560

please note that i have the latest version of xamarin.
any help would be highly appreciated.
Thank you