Bug 27874 - Android NullPointerException updating observable collection
Summary: Android NullPointerException updating observable collection
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-11 08:10 UTC by Andy
Modified: 2015-10-27 09:29 UTC (History)
5 users (show)

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

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 Andy 2015-03-11 08:10:28 UTC
The main page of our application contains a Tabbed page with 3 tabs bound to 3 observable collections on our view model
These collections are really just filtered views on the a single main observable collection.
OnAppearing the page requests data from the view model causing the main collection and hence the filtered collections to change loading the lists. This all works fine on iOS and on our Windows universal implementation(Not Xamarin but using same pcls) but on Android, 2 times our of 3, it crashes with the below exception.

If you step through the code in the debugger it works every time. This leads me to believe it is a timing issue with the collections being modified whilst the Lists are being rendered on the page.

03-10 14:50:14.337 I/mono-stdout(28139): Get Summary Containers for 98751648-9a82-4aeb-b196-1a2ca4702a27
An unhandled exception occured.

Thread started: <Thread Pool> #8
03-10 14:50:22.307 E/mono    (28139): 
03-10 14:50:22.307 E/mono    (28139): Unhandled Exception:
03-10 14:50:22.307 E/mono    (28139): Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
03-10 14:50:22.307 E/mono    (28139):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896 
03-10 14:50:22.307 E/mono    (28139):   at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue[] constructorParameters) [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:288 
03-10 14:50:22.307 E/mono    (28139):   at Android.OS.Handler..ctor (Android.OS.Looper looper) [0x000ef] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.OS.Handler.cs:179 
03-10 14:50:22.307 E/mono    (28139):   at Android.App.SyncContext.Post (System.Threading.SendOrPostCallback d, System.Object state) [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/9e05e39f/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:17 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.SynchronizationContextContinuation.Execute () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.Task.ProcessCompleteDelegates () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.Task.Finish () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.Task.Execute () [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   at System.Threading.Tasks.TpScheduler.TaskExecuterCallback (System.Object obj) [0x00000] in <filename unknown>:0 
03-10 14:50:22.307 E/mono    (28139):   --- End of managed exception stack trace ---
03-10 14:50:22.307 E/mono    (28139): java.lang.NullPointerException
03-10 14:50:22.307 E/mono    (28139): 	at android.os.Handler.<init>(Handler.java:226)
03-10 14:50:22.307 E/mono    (28139): 	at android.os.Handler.<init>(Handler.java:134)
03-10 14:50:22.307 E/mono    (28139): 	at dalvik.system.NativeStart.run(Native Method)
Comment 1 Rui Marinho 2015-05-21 20:47:38 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue we would very much appreciate it. We monitor recently touched NEEDS INFO bugs so we’ll notice you attached the reproduction we’ll take it from there. 

Warm regards,
Xamarin Forms Team
Comment 2 Andy 2015-10-27 09:22:40 UTC
This issue appears to have gone away on xamarin 1.5 I can only assume it was fixed inadvertently as part of some change since 1.4.4
Comment 3 Rui Marinho 2015-10-27 09:29:08 UTC
Thanks , please reopen if you stills issues later