Bug 31623 - Fatal exception at Xamarin.Forms.Platform.Android.NavigationRenderer
Summary: Fatal exception at Xamarin.Forms.Platform.Android.NavigationRenderer
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-03 08:57 UTC by Andy
Modified: 2018-03-01 13:11 UTC (History)
7 users (show)

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


Attachments
screen shot mashed display (87.45 KB, image/png)
2015-07-03 08:57 UTC, Andy
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 ANSWERED

Description Andy 2015-07-03 08:57:47 UTC
Created attachment 11844 [details]
screen shot mashed display

Our app's main page is a Master detail page.
Our app was functioning fine on version 1.4.2.6359
After updating to 1.4.3.6374 when we attempt to navigate in detail page we get the following fatal exception

07-03 13:09:28.274 I/MonoDroid(23973): UNHANDLED EXCEPTION:
07-03 13:09:28.284 I/MonoDroid(23973): System.NullReferenceException: Object reference not set to an instance of an object
07-03 13:09:28.284 I/MonoDroid(23973): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClass8.<SwitchContentAsync>b__3 (Android.Animation.Animator) <IL 0x00065, 0x0021c>
07-03 13:09:28.284 I/MonoDroid(23973): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClassa.<SwitchContentAsync>b__4 (Android.Animation.Animator) <IL 0x0000d, 0x0007b>
07-03 13:09:28.284 I/MonoDroid(23973): at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator) <IL 0x0000f, 0x000ab>
07-03 13:09:28.284 I/MonoDroid(23973): at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Animation.AnimatorListenerAdapter.cs:105
07-03 13:09:28.284 I/MonoDroid(23973): at (wrapper dynamic-method) object.80d5a2f9-0029-4720-9442-95b1d8fd6ed1 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
07-03 13:09:28.314 D/Mono    (23973): Assembly Ref addref Mono.Android[0x583b2790] -> System[0x59b4f128]: 16
07-03 13:09:33.684 I/dalvikvm(23973): Could not find method java.lang.Throwable.<init>, referenced from method md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable.<init>
07-03 13:09:33.684 W/dalvikvm(23973): VFY: unable to resolve direct method 9673: Ljava/lang/Throwable;.<init> (Ljava/lang/String;Ljava/lang/Throwable;ZZ)V
07-03 13:09:33.684 D/dalvikvm(23973): VFY: replacing opcode 0x70 at 0x0000
07-03 13:09:33.714 D/AndroidRuntime(23973): Shutting down VM
07-03 13:09:33.714 W/dalvikvm(23973): threadid=1: thread exiting with uncaught exception (group=0x420d08e0)
An unhandled exception occured.

07-03 13:09:35.744 E/AndroidRuntime(23973): FATAL EXCEPTION: main
07-03 13:09:35.744 E/AndroidRuntime(23973): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at dalvik.system.NativeStart.main(Native Method)
07-03 13:09:35.744 E/AndroidRuntime(23973): Caused by: java.lang.reflect.InvocationTargetException
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.animation.ValueAnimator$Animat07-03 13:09:35.744 E/AndroidRuntime(23973): 	at java.lang.reflect.Method.invoke(Method.java:525)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	... 2 more
07-03 13:09:35.744 E/AndroidRuntime(23973): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
07-03 13:09:35.744 E/AndroidRuntime(23973): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClass8.<SwitchContentAsync>b__3 (Android.Animation.Animator) <IL 0x00065, 0x0021c>
07-03 13:09:35.744 E/AndroidRuntime(23973): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClassa.<SwitchContentAsync>b__4 (Android.Animation.Animator) <IL 0x0000d, 0x0007b>
07-03 13:09:35.744 E/AndroidRuntime(23973): at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator) <IL 0x0000f, 0x000ab>
07-03 13:09:35.744 E/AndroidRuntime(23973): at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Animation.AnimatorListenerAdapter.cs:105
07-03 13:09:35.744 E/AndroidRuntime(23973): at (wrapper dynamic-method) object.80d5a2f9-0029-4720-9442-95b1d8fd6ed1 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
07-03 13:09:35.744 E/AndroidRuntime(23973): 
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.n_onAnimationEnd(Native Method)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at md5530bd51e982e6e7b340b73e88efe666e.GenericAnimatorListener.onAnimationEnd(GenericAnimatorListener.java:46)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:982)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1020)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:630)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:646)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.view.Choreographer.doCallbacks(Choreographer.java:562)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.view.Choreographer.doFrame(Choreographer.java:531)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.os.Handler.handleCallback(Handler.java:730)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.os.Handler.dispatchMessage(Handler.java:92)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.os.Looper.loop(Looper.java:137)
07-03 13:09:35.744 E/AndroidRuntime(23973): 	at android.app.ActivityThread.main(ActivityThread.java:5473)

I noticed that the error referred to  Xamarin.Forms.Platform.Android.NavigationRenderer so I implemented the most basic custom Navigation renderer as folows

public class NavigationPageRenderer : PageRenderer
    {
        /// <summary>
        /// Raises the <see cref="E:ElementChanged" /> event.
        /// </summary>
        /// <param name="e">The <see cref="ElementChangedEventArgs{Page}"/> instance containing the event data.</param>
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {            
            base.OnElementChanged(e);
        }
    }

and the crash went away. however when we navigate in the detail window again the new page is displayed over the existing page giving you a mixture of both pages (list and detail both visible)
see screen shot. It did not do this before, I don't know if this is the custom renderer or another bug!

We will be reverting back to version 1.4.2.6359 until this issue is resolved.
Comment 1 Rajneesh Kumar 2015-07-06 06:54:18 UTC
I tried to reproduce this issue but not able to reproduce this. Could you please provide me a small sample that demonstrate this issue. That would be very helpful to reproduce this issue at our end.

Thanks..!
Comment 2 CB 2015-07-14 09:56:52 UTC
I've experienced the same thing using PopToRootAsync to pop a stack of modal views. I worked around it by setting the animate flag to false.
Comment 3 Trevor 2015-08-13 20:08:09 UTC
Thank you CB! I have this crash on Android w Xamarin Forms 1.4.4, and PopToRootAsync(false) fixed it for me as well.
Comment 4 Andy 2015-10-27 09:18:27 UTC
Finally stumbled across the solution. 
Basically we had a master detail page and we set the detail to a mainPage.Detail = new NavigationPage(somePage1). Then later we set the detail to another navigation page e.g.  mainPage.Detail = new NavigationPage(somepage2). I guess that orphaned somepage1 whilst android was still trying to do something with it (animate?).
Simply navigating within the first navigation page rather than replacing it fixed the issue.
Note the issue was random on 1.4.4 but 1.5 it happened all the time
Comment 5 gpatkos 2018-03-01 13:11:16 UTC
I have experienced the same issue when I tried to set the Detail property to a new page wrapped with a NavigationPage. Unfortunately your solution did not work for me, but I fixed it by forcing the new page creation on the main thread:

Device.BeginInvokeOnMainThread(() => { 
	Page newPage = (Page)Activator.CreateInstance(typeOfPage);
	Detail = new NavigationPage(newPage);
});

I hope this will help somebody.

I have Xamarin Forms 2.5.0.122203.