Bug 32635 - App crashes when the view contains animation and you relaunch the app
Summary: App crashes when the view contains animation and you relaunch the app
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.4
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-07-30 15:57 UTC by ashok.adhikari18
Modified: 2016-04-11 09:49 UTC (History)
6 users (show)

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:

Description ashok.adhikari18 2015-07-30 15:57:54 UTC
App will crash when I navigate to different view from the view containing animation, exit the app with back button and relaunch the app. This started happening after Xamarin.Forms update to 1.4.3. It exists on 1.4.4 as well.

Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException
  at --- End of managed exception stack trace ---
  at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
  at at dalvik.system.NativeStart.main(Native Method)
  at Caused by: java.lang.reflect.InvocationTargetException
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
  at ... 2 more
  at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
  at Parameter name: jobject
  at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr) [0x00010] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:546
  at Android.Animation.Animator.Cancel () [0x00043] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Animation.Animator.cs:839
  at at Xamarin.Forms.Platform.Android.AndroidTicker.DisableTimer () <IL 0x00006, 0x00053>
  at at Xamarin.Forms.Ticker.Disable () <IL 0x0000c, 0x00083>
  at at Xamarin.Forms.Ticker.SendSignals (int) <IL 0x000bc, 0x00683>
  at at Xamarin.Forms.Platform.Android.AndroidTicker.<.ctor>b__0 (object,Android.Animation.ValueAnimator/AnimatorUpdateEventArgs) <IL 0x00002, 0x0004f>
  at Android.Animation.ValueAnimator/IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator) [0x0000d] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Animation.ValueAnimator.cs:136
  at Android.Animation.ValueAnimator/IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1879/5f55a9ef/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Animation.ValueAnimator.cs:85
  at at (wrapper dynamic-method) object.c231dd54-390e-4438-a7c0-aefdc92c08d0 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
  at at mono.android.animation.ValueAnimator_AnimatorUpdateListenerImplementor.n_onAnimationUpdate(Native Method)
  at at mono.android.animation.ValueAnimator_AnimatorUpdateListenerImplementor.onAnimationUpdate(ValueAnimator_AnimatorUpdateListenerImplementor.java:29)
  at at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1251)
  at at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1175)
  at at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1216)
  at at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:637)
  at at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
  at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
  at at android.view.Choreographer.doCallbacks(Choreographer.java:613)
  at at android.view.Choreographer.doFrame(Choreographer.java:582)
  at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
  at at android.os.Handler.handleCallback(Handler.java:733)
  at at android.os.Handler.dispatchMessage(Handler.java:95)
  at at android.os.Looper.loop(Looper.java:146)
  at at android.app.ActivityThread.main(ActivityThread.java:5694)
  at ... 5 more
Comment 1 Chris King 2015-07-31 13:01:13 UTC
Thanks for submitting this bug. We give priority to bugs with attached
reproductions so if you could you please zip up your project and upload it as
an attachment to the bug that would expedite resolution of your issue. If you're able to strip out functionality that is not needed to reproduce the issue that would also aid in our investigation. 

Warm regards,
Comment 2 ashok.adhikari18 2015-07-31 13:25:24 UTC
I am animating a button using this code behind logic: When I leave the view containing this animated button by hitting back button and relaunch the app to get to the same view, it crashes every single time.	

void AnimateButton (Button button)
                    animation= new Animation ((double f) => button.Scale = f, button.Scale, 0.85,
					Easing.Linear, null
			animation.Commit(button, "ScaleTo", 16, 1000, Easing.SpringIn,
				delegate(double f, bool a)
				button.Scale = 1.0;
				() => button.IsVisible

I tried to abort animation on OnDisappearing() with these methods:
The frequency of crash was decreased from every single time to every 4-5 repetition of exiting app and relaunching it.

If I remove the animation from view, there is no issue.
Comment 3 Paul Roy 2015-11-13 09:13:09 UTC
Have you find out a fix ? I'm stuck on the exact same problem…
Comment 4 adrianknight89 2015-12-21 03:51:51 UTC

I'm having a similar issue. This is only happening on Android. I created a thread here: https://forums.xamarin.com/discussion/58006/proper-way-to-abort-animation#latest

For repro, use Ashok's sample and animate a random button. This is happening on

In my use case, hitting the Back button and re-launching the app will crash the app if the current page has an animation (It doesn't have to be like Ashok's multi-page setup). My home screen has an animation. Perhaps the animation object is not being properly destroyed?

Handling OnDisappearing helps, but it's useless if the app is re-launched immediately after it's killed.

Comment 5 Andy 2016-01-06 18:00:40 UTC
This is happening in our product as well. What should we do? All of the information seems to be there, so the status should be changed from NEEDINFO soon.
Comment 7 Jason Smith [MSFT] 2016-04-11 09:49:49 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team