Bug 35407 - jobject muste not be IntPtr.Zero with Animation
Summary: jobject muste not be IntPtr.Zero with Animation
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-10-30 12:29 UTC by Paul Roy
Modified: 2016-04-25 13:49 UTC (History)
6 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 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:
VERIFIED FIXED

Description Paul Roy 2015-10-30 12:29:07 UTC
I have an animation on my main page, closing the app and re-openning it on Android causes every time an exception.

Nothing seems to help, aborting the animation, setting each component to null, anything…

I use NControl on my code, but this seems to come from the framework (as they don't have the issue on their project with the same snippet of code)

I have the following stacktrace to help you debug :
e.Exception.StackTrace	"  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod) [0x00010] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:546 
  at Android.Animation.Animator.Cancel () [0x00043] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.Animator.cs:839 
  at Xamarin.Forms.Platform.Android.AndroidTicker.DisableTimer () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Ticker.Disable () [0x0000b] in <filename unknown>:0 
  at Xamarin.Forms.Ticker.SendSignals (Int32 timestep) [0x000ab] in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.AndroidTicker.<.ctor>b__1_0 (System.Object sender, Android.Animation.AnimatorUpdateEventArgs e) [0x00000] in <filename unknown>:0 
  at Android.Animation.ValueAnimator+IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator animation) [0x0000d] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.ValueAnimator.cs:136 
  at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (IntPtr jnienv, IntPtr native__this, IntPtr native_animation) [0x00011] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.ValueAnimator.cs:85 
  at (wrapper dynamic-method) object:ccedcbc9-6466-4efc-b3c7-8ce243d9e0d2 (intptr,intptr,intptr)"	string
Comment 1 Paul Roy 2015-10-30 12:33:06 UTC
Sorry, I forgot to remove a few things for the stackTrace :

System.ArgumentException: 'jobject' must not be IntPtr.Zero.
Parameter name: jobject
  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod) [0x00010] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:546 
  at Android.Animation.Animator.Cancel () [0x00043] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.Animator.cs:839 
  at Xamarin.Forms.Platform.Android.AndroidTicker.DisableTimer () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Ticker.Disable () [0x0000b] in <filename unknown>:0 
  at Xamarin.Forms.Ticker.SendSignals (Int32 timestep) [0x000ab] in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.AndroidTicker.<.ctor>b__1_0 (System.Object sender, Android.Animation.AnimatorUpdateEventArgs e) [0x00000] in <filename unknown>:0 
  at Android.Animation.ValueAnimator+IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator animation) [0x0000d] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.ValueAnimator.cs:136 
  at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (IntPtr jnienv, IntPtr native__this, IntPtr native_animation) [0x00011] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Animation.ValueAnimator.cs:85 
  at (wrapper dynamic-method) object:f2814465-6364-4f90-b356-e043484df4f1 (intptr,intptr,intptr)
Comment 2 Paul DiPietro [MSFT] 2015-10-30 14:16:47 UTC
We would need a reproduction to be able to investigate what's occurring.
Comment 3 Paul Roy 2015-10-31 08:00:47 UTC
I'm sorry, I can't take the time to create a project to reproduce, I'm on a tight deadline.

Basically, I have a splashscreen activity (MainLauncher = true, NoHistory = true) that initialize services and then opens a MainActivity (FormsApplicationActivity), which loads the Forms App.

The forms App has an animation declared. I believe the application is trying to work on an animation that no longer exists when the splashscreen is opened a second time.

I understand a repro case would be the best option for you, but this stacktrace also gives a lot of informations. I would be glad to help if this was open sourced, but I can't take half a day to recreate a reproduction scenario right now.


PS: this really happens litterally every single time I open / close / re-open my application. I had a lot of other troubles with the exact same scenario, I think you should try this set-up (Splashscreen + FormsApplicationActivity) to test the reliability of xamarin forms.
Comment 5 Michael van der Horst 2015-12-24 11:03:31 UTC
Hi Paul,

We could reproduce this problem.
For us, it appears when we try to move our relative layout back in the view, whilst starting up the application. The splashscreen is showing and our animation want to animate.
The log keeps filling with the exception, while the app is working.
                    await rl.TranslateTo(0, 0, (uint)0); 

We resolved this by resettings the relative layout before closing the app and setting it to Invisible, then when opening the app and start the relative layout, we just set it to Visible again.

Another possible solution could be to delay your animation, wait until your view is displayed completely.

Regards,
Michael
Comment 6 Chris Towles 2016-02-05 14:38:15 UTC
I was experiencing this issue about 30% of the time closing the app when a screen using a RelativeLayout. I was using on Android 6.0 using Nexus 6P with “Developer Options” set to “Don’t Keep Activities”.  Using Xamarin.Forms version “2.0.1.6505”


Based on the information above I looked into the “IsVisible” setting and tried setting it IsVisible="True" in the Xaml  and then toggling it on and off with Page OnAppearing() and OnDisappearing(). That worked after testing it with 20 app reopens to that page. 

I then noticed that I didn’t need to add the toggle, just adding IsVisible=”True” to the RelativeLayout solved the issue, I tested another 20 app reopens and couldn’t reproduce the “System.ArgumentException: 'jobject' must not be IntPtr.Zero.”  crash.
 
<RelativeLayout  ... IsVisible="True">


Hope this gives some others a work around and helps narrow down the root cause,
Chris
Comment 7 Rui Marinho 2016-03-17 11:02:59 UTC
Should be fixed in 2.2.0-pre1
Comment 8 Paul Roy 2016-03-17 11:22:55 UTC
I can confirm as soon as the package is out.
Comment 9 Parmendra Kumar 2016-04-25 13:49:52 UTC
I have checked this issue with Xamarin.Forms 2.2.0-pre1 and its working fine at my end.

Hence closing this issue.

If you still facing same issue please feel free to reopen this issue.