1
votes

I have created a simple navigation app in which there are multiple screens which contain Pickers, ListViews, buttons, and images using Skia sharp SVG.

Everything seems to function right but sometimes it randomly throws an exception at any random position. Even when I leave the app open for some time I get the same exception.

The error it gives is

Collection was modified; enumeration operation may not execute".

I tried to debug it. Every time it crashes and the following stack trace appeared:

at System.Collections.Generic.List1+Enumerator[T].MoveNextRare () [0x00013] in <58604b4522f748968296166e317b04b4>:0 at System.Collections.Generic.List1+Enumerator[T].MoveNext () [0x0004a] in <58604b4522f748968296166e317b04b4>:0 at Xamarin.Forms.Platform.Android.VisualElementTracker.HandleRedrawNeeded (System.Object sender, Xamarin.Forms.Internals.EventArg`1[T] e) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:180 at Xamarin.Forms.VisualElement.BatchCommit () [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:581 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 <2960acf2eeb24d88b5230e1e8afbdc2e>:0 at Android.Animation.ValueAnimator+IAnimatorUpdateListenerInvoker.n_OnAnimationUpdate_Landroid_animation_ValueAnimator_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_animation) [0x00011] in <2960acf2eeb24d88b5230e1e8afbdc2e>:0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.17(intptr,intptr,intptr)

Tools:

  • Visual Studio for Mac: 8.0.3 (build 14)
  • Xamarin Mac Development: 8.0.2

Testing Devices:

  • Samsung Galaxy S9
  • Lenovo Tab 3 7
  • One Plus 5T
1
Looking at the stack, seems something in your animation code is causing the problem. What is your code for the Forms' Animations that are running?SushiHangover
The only place i m using animation is i am rotating my custom Activity indicator. Its code is as follow Task.Run(() => RotateImageContinously(Circle1, 300)); async Task RotateImageContinously(SvgXF.Icon image, uint timeForOnChunck) { while (IsVisible) // a CancellationToken in real life ;-) { for (int i = 1; i < 7; i++) { if (image.Rotation >= 360f) image.Rotation = 0; await image.RotateTo(i * (360 / 6), timeForOnChunck, Easing.Linear); } } }Umair Bhatti
Btw Thanks for the quick reply and giving me a direction to investigate the issue (y)Umair Bhatti
@UmairBhatti Hi, Have you solved this problem?Junior Jiang
@JuniorJiang-MSFT Sorry for late reply. In my case the thing fixed the issue is, i was showing a custom activity indicator view on all pages to show loading. In the cs of that view i was running 3 task to rotate 3 circles to show loading continuously with a wait of some millisecond and was never stopping the task. For some odd reason when i added an implementation that when page disappears it stops the all the tasks fixed this issue at my end. its weird but it did work for me.Umair Bhatti

1 Answers

0
votes

In my case the thing fixed the issue is, i was showing a custom activity indicator view on all pages to show loading. In the cs of that view i was running 3 task to rotate 3 circles to show loading continuously with a wait of some millisecond and was never stopping the task. For some odd reason when i added an implementation that when page disappears it stops the all the tasks fixed this issue at my end. its weird but it did work for me.