Xamarin animation crashes app

I am developing card game in xamarin form. I
am doing animation like card moving or chip moving from one place other place sometime it works sometimes it's crashes directly. Anybody facing this sort of issue and if having solution to solve this solution. Please help me...

Best Answer

Answers

  • AmitKDAmitKD Member ✭✭

    Thank John for your reply I have attached code below when I click on button OnSetPlayerSeatControlAction this is click event.
    private void OnSetPlayerSeatControlAction(){
    await RunCardAniation().ContinueWith(v=> RunCardAniation());
    }
    private void RunCardAniation()
    {
    ObjAnimationList.Clear();
    ObjAnimationList.Add(GetAnimationObject(1));
    ObjAnimationList.Add(GetAnimationObject(2));
    await Task.WhenAll(ObjAnimationList);
    await Task.Delay(400);
    }

    public Task GetAnimationObject(int num)
    {
    switch (num)
    {
    case 1:
    return Task.Delay(100).ContinueWith(v => DealCards1.FadeTo(1).ContinueWith(v1 => DealCards1.TranslateTo(100, 200).ContinueWith(v2 => { DealCards1.Opacity = 0; DealCards1.TranslateTo(0, 0); })));
    break;
    case 2:
    return Task.Delay(200).ContinueWith(v => DealCards2.FadeTo(1).ContinueWith(v1 => DealCards2.TranslateTo(-100, 200).ContinueWith(v2 => { DealCards2.Opacity = 0; DealCards2.TranslateTo(0, 0); })));
    break;
    default:
    return Task.Delay(500).ContinueWith(v => DealCards5.FadeTo(1).ContinueWith(v1 => DealCards5.TranslateTo(100, 200).ContinueWith(v2 => { DealCards4.Opacity = 0; DealCards5.TranslateTo(0, 0); })));
    break;
    }
    }

    when I tap 2,3 times continuously some times it run sometime it crashes.

  • JohnHardmanJohnHardman GBUniversity mod

    @AmitKD

    The code you posted above will not compile. If you are still having problems, post the code that you are actually running, together with details of the exceptions thrown.

  • AmitKDAmitKD Member ✭✭

    02-18 12:51:27.068 I/MonoDroid( 9405): System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
    02-18 12:51:27.069 I/MonoDroid( 9405): at System.Collections.Generic.List1+Enumerator[T].MoveNextRare () [0x00013] in <43dbbdc147f2482093d8409abb04c233>:0 02-18 12:51:27.069 I/MonoDroid( 9405): at System.Collections.Generic.List1+Enumerator[T].MoveNext () [0x0004a] in <43dbbdc147f2482093d8409abb04c233>:0
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.Platform.Android.VisualElementTracker.HandleRedrawNeeded (System.Object sender, Xamarin.Forms.Internals.EventArg1[T] e) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:180 02-18 12:51:27.069 I/MonoDroid( 9405): at (wrapper delegate-invoke) System.EventHandler1[Xamarin.Forms.Internals.EventArg1[Xamarin.Forms.VisualElement]].invoke_void_object_TEventArgs(object,Xamarin.Forms.Internals.EventArg1<Xamarin.Forms.VisualElement>)
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.VisualElement.BatchCommit () [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:581
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.AnimationExtensions.HandleTweenerFinished (System.Object o, System.EventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\AnimationExtensions.cs:276
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.Tweener.b__22_0 (System.Int64 step) [0x00095] in D:\a\1\s\Xamarin.Forms.Core\Tweener.cs:103
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int64 step) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:102
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int32 timestep) [0x00014] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:91
    02-18 12:51:27.069 I/MonoDroid( 9405): at Xamarin.Forms.Platform.Android.AndroidTicker.OnValOnUpdate (System.Object sender, Android.Animation.ValueAnimator+AnimatorUpdateEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AndroidTicker.cs:71
    02-18 12:51:27.069 I/MonoDroid( 9405): at Android.Animation.ValueAnimator+IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator animation) [0x00017] in :0
    02-18 12:51:27.069 I/MonoDroid( 9405): at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_animation) [0x00011] in :0
    02-18 12:51:27.069 I/MonoDroid( 9405): at (wrapper dynamic-method) System.Object.17(intptr,intptr,intptr)
    02-18 12:51:27.091 W/art ( 9405): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
    02-18 12:51:27.098 D/Mono ( 9405): DllImport searching in: '__Internal' ('(null)').
    02-18 12:51:27.098 D/Mono ( 9405): Searching for 'java_interop_jnienv_throw'.
    02-18 12:51:27.098 D/Mono ( 9405): Probing 'java_interop_jnienv_throw'.
    02-18 12:51:27.098 D/Mono ( 9405): Found as 'java_interop_jnienv_throw'.
    An unhandled exception occured.

  • JohnHardmanJohnHardman GBUniversity mod

    @JohnHardman said:
    @AmitKD

    The code you posted above will not compile. If you are still having problems, post the code that you are actually running, together with details of the exceptions thrown.

  • AmitKDAmitKD Member ✭✭

    at System.Collections.Generic.List1+Enumerator[T].MoveNextRare () [0x00013] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Collections.Generic.List1+Enumerator[T].MoveNext () [0x0004a] in <43dbbdc147f2482093d8409abb04c233>:0
    at Xamarin.Forms.Platform.Android.VisualElementTracker.HandleRedrawNeeded (System.Object sender, Xamarin.Forms.Internals.EventArg1[T] e) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:180 at (wrapper delegate-invoke) System.EventHandler1[Xamarin.Forms.Internals.EventArg1[Xamarin.Forms.VisualElement]].invoke_void_object_TEventArgs(object,Xamarin.Forms.Internals.EventArg1<Xamarin.Forms.VisualElement>)
    at Xamarin.Forms.VisualElement.BatchCommit () [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:574
    at Xamarin.Forms.AnimationExtensions.HandleTweenerFinished (System.Object o, System.EventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\AnimationExtensions.cs:276
    at Xamarin.Forms.Tweener.b__22_0 (System.Int64 step) [0x00095] in D:\a\1\s\Xamarin.Forms.Core\Tweener.cs:103
    at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int64 step) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:102
    at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int32 timestep) [0x00014] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:91
    at Xamarin.Forms.Platform.Android.AndroidTicker.OnValOnUpdate (System.Object sender, Android.Animation.ValueAnimator+AnimatorUpdateEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AndroidTicker.cs:71
    at Android.Animation.ValueAnimator+IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator animation) [0x00017] in :0
    at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_animation) [0x00011] in :0
    at (wrapper dynamic-method) System.Object.17(intptr,intptr,intptr)

  • AmitKDAmitKD Member ✭✭

    at System.Collections.Generic.List1+Enumerator[T].MoveNextRare () [0x00013] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Collections.Generic.List1+Enumerator[T].MoveNext () [0x0004a] in <43dbbdc147f2482093d8409abb04c233>:0
    at Xamarin.Forms.Platform.Android.VisualElementTracker.HandleRedrawNeeded (System.Object sender, Xamarin.Forms.Internals.EventArg1[T] e) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:180 at (wrapper delegate-invoke) System.EventHandler1[Xamarin.Forms.Internals.EventArg1[Xamarin.Forms.VisualElement]].invoke_void_object_TEventArgs(object,Xamarin.Forms.Internals.EventArg1<Xamarin.Forms.VisualElement>)
    at Xamarin.Forms.VisualElement.BatchCommit () [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:574
    at Xamarin.Forms.AnimationExtensions.HandleTweenerFinished (System.Object o, System.EventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\AnimationExtensions.cs:276
    at Xamarin.Forms.Tweener.b__22_0 (System.Int64 step) [0x00095] in D:\a\1\s\Xamarin.Forms.Core\Tweener.cs:103
    at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int64 step) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:102
    at Xamarin.Forms.Internals.Ticker.SendSignals (System.Int32 timestep) [0x00014] in D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:91
    at Xamarin.Forms.Platform.Android.AndroidTicker.OnValOnUpdate (System.Object sender, Android.Animation.ValueAnimator+AnimatorUpdateEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AndroidTicker.cs:71
    at Android.Animation.ValueAnimator+IAnimatorUpdateListenerImplementor.OnAnimationUpdate (Android.Animation.ValueAnimator animation) [0x00017] in :0
    at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_animation) [0x00011] in :0
    at (wrapper dynamic-method) System.Object.17(intptr,intptr,intptr)

Sign In or Register to comment.