Bug 54422 - android.runtime.JavaProxyThrowable: System.NullReferenceException -> IPlatformLayout.OnLayout(bool changed, int l, int t, int r, int b)
Summary: android.runtime.JavaProxyThrowable: System.NullReferenceException -> IPlatfor...
Status: ASSIGNED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-04 01:19 UTC by jcaptanis
Modified: 2017-04-06 02:09 UTC (History)
4 users (show)

Tags:
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 for Bug 54422 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
ASSIGNED

Description jcaptanis 2017-04-04 01:19:29 UTC
Im getting regular crashes with this framework code. My guess is it happens when the screen is locked and my app receives some data, because i can sometimes repo this if i start a debug session with the phone locked.

https://github.com/xamarin/Xamarin.Forms/blob/e6d5186c8acbf37b877c7ca3c77a378352a3743d/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs

Android: 6.0.1
Android Build: MMB29M.G900IDVU1CPL1
Manufacturer: samsung
Model: SM-G900I
Thread: main-1
CrashReporter Key: 7B870E53-2552-4B05-E1B2-CA329D6456C6D0CE2CB9
Start Date: Wed Mar 01 19:33:44 GMT+08:00 2017
Date: Wed Mar 01 20:10:14 GMT+08:00 2017
Format: Xamarin

Android Build: 32.3.A.0.376
Manufacturer: Sony
Model: E6653
Thread: main-1
CrashReporter Key: A6F457A0-C450-41EA-7049-8FEC2C90928040078013
Start Date: Thu Mar 16 17:14:33 GMT+00:00 2017
Date: Thu Mar 16 17:14:48 GMT+00:00 2017
Format: Xamarin


Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout(bool changed, int l, int t, int r, int b)<eed8aa96500949579ca8d725b7c74dd0>:0
Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout(bool changed, int l, int t, int r, int b)<eed8aa96500949579ca8d725b7c74dd0>:0
Android.Views.ViewGroup.n_OnLayout_ZIIII(IntPtr jnienv, IntPtr native__this, bool changed, int l, int t, int r, int b)<d9d314934fb948b78010c2cb29959367>:0
at (wrapper dynamic-method) System.Object:6069368a-afd0-42db-af30-abcf6b1d49b2 (intptr,intptr,bool,int,int,int,int)
md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout()PlatformRenderer.java:55
android.view.View.layout()View.java:17938
android.view.ViewGroup.layout()ViewGroup.java:5812
android.widget.RelativeLayout.onLayout()RelativeLayout.java:1080
android.view.View.layout()View.java:17938
android.view.ViewGroup.layout()ViewGroup.java:5812
android.widget.FrameLayout.layoutChildren()FrameLayout.java:344
android.widget.FrameLayout.onLayout()FrameLayout.java:281
android.view.View.layout()View.java:17938
android.view.ViewGroup.layout()ViewGroup.java:5812
android.widget.LinearLayout.setChildFrame()LinearLayout.java:1742
android.widget.LinearLayout.layoutVertical()LinearLayout.java:1585
android.widget.LinearLayout.onLayout()LinearLayout.java:1494
android.view.View.layout()View.java:17938
android.view.ViewGroup.layout()ViewGroup.java:5812
android.widget.FrameLayout.layoutChildren()FrameLayout.java:344
android.widget.FrameLayout.onLayout()FrameLayout.java:281
com.android.internal.policy.PhoneWindow$DecorView.onLayout()PhoneWindow.java:3193
android.view.View.layout()View.java:17938
android.view.ViewGroup.layout()ViewGroup.java:5812
android.view.ViewRootImpl.performLayout()ViewRootImpl.java:2666
android.view.ViewRootImpl.performTraversals()ViewRootImpl.java:2367
android.view.ViewRootImpl.doTraversal()ViewRootImpl.java:1437
android.view.ViewRootImpl$TraversalRunnable.run()ViewRootImpl.java:7397
android.view.Choreographer$CallbackRecord.run()Choreographer.java:920
android.view.Choreographer.doCallbacks()Choreographer.java:695
android.view.Choreographer.doFrame()Choreographer.java:631
android.view.Choreographer$FrameDisplayEventReceiver.run()Choreographer.java:906
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:158
android.app.ActivityThread.main()ActivityThread.java:7224
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1120
Comment 1 Jake Barrow 2017-04-04 12:01:09 UTC
I'm also getting this. It appears to happen when I set the main page, but only after I've used GoogleSignIn to authenticate the user?

It occurs on Android 5.0.1 and Android 6.0.1 but does not occur on Android 7.1.1
Comment 2 Paul DiPietro [MSFT] 2017-04-04 13:46:31 UTC
Could one of you please upload a minimized reproduction with steps on how to get the error to occur?
Comment 3 Jake Barrow 2017-04-05 08:51:05 UTC
I found a solution for my issue, as it was a consistent error.

It turns out that the GoogleSignIn Activity I was using pushed the MainActivity to the background. Changing the main page whilst this was in the background caused the error, to solve this I had to called {MyGoogleSignInActivity}.Finish(); before executing the code to change the main page.
Comment 4 jcaptanis 2017-04-06 01:43:56 UTC
I dont have a reliable repo sorry...

So the problem is changing the current page while the app is backgrounded? Could we get a proper error instead of a wierd nullref exception?

and then, what is the recommended way to detect if a page is in the background 

Xamarin.Forms.Application:
protected override void OnResume()
protected override void OnSleep()

?
Comment 5 jcaptanis 2017-04-06 02:09:03 UTC
Or could we just get a nullcheck in this method to save us from this?


I think this is also my problem with this crash --> i dont ever "setstate" so i dont know what i am doing wrong... My app is highly "reactive" so i might be hitting race conditions in the framework when coming from background, not waiting for things to render.

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
android.support.v4.app.FragmentManagerImpl.checkStateLoss()FragmentManager.java:1493
android.support.v4.app.FragmentManagerImpl.enqueueAction()FragmentManager.java:1511
android.support.v4.app.BackStackRecord.commitInternal()BackStackRecord.java:638
android.support.v4.app.BackStackRecord.commit()BackStackRecord.java:617
android.support.v4.app.DialogFragment.show()DialogFragment.java:139
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.app.Activity.runOnUiThread()Activity.java:6035
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:158
android.app.ActivityThread.main()ActivityThread.java:7225
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1120
Xamarin caused by: Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()<90ec9c924ee649a6a0c42673073e8c14>:0
Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)<84e54fc55ca84705b660a2f18740b36e>:0
Android.Runtime.JNIEnv.CallNonvirtualVoidMethod(IntPtr jobject, IntPtr jclass, IntPtr jmethod, JValue* parms)<d9d314934fb948b78010c2cb29959367>:0
Android.Support.V4.App.DialogFragment.Show(FragmentManager manager, string tag)<27c17fe440cf491ba8255bcefade6e02>:0
Acr.UserDialogs.UserDialogsImpl.<>c__DisplayClass26_0<TFragment, TConfig>.<ShowDialog>b__0()<74ea0cacc10942059c2f2e1dc6aab924>:0
Java.Lang.Thread.RunnableImplementor.Run()<d9d314934fb948b78010c2cb29959367>:0
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<d9d314934fb948b78010c2cb29959367>:0
at (wrapper dynamic-method) System.Object:08cc6af6-b705-4545-8b95-0ff12d660707 (intptr,intptr)
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
android.support.v4.app.FragmentManagerImpl.checkStateLoss()FragmentManager.java:1493
android.support.v4.app.FragmentManagerImpl.enqueueAction()FragmentManager.java:1511
android.support.v4.app.BackStackRecord.commitInternal()BackStackRecord.java:638
android.support.v4.app.BackStackRecord.commit()BackStackRecord.java:617
android.support.v4.app.DialogFragment.show()DialogFragment.java:139
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.app.Activity.runOnUiThread()Activity.java:6035
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:158
android.app.ActivityThread.main()ActivityThread.java:7225
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:1120