Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.36k stars 351 forks source link

IndexOutOfRangeException: Array index is out of range. #16

Open andrew-chewie opened 9 years ago

andrew-chewie commented 9 years ago

DoTween version v1.0.665

This errors started to happen when a big amount of tweens launch at the same time on different objects (100-300 tween). Maybe there is situations when 2-3 similar tweens start on the same object and same parameter.

IndexOutOfRangeException: Array index is out of range. DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:786) DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:400) DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50)

And the second one, similar:

IndexOutOfRangeException: Array index is out of range. (wrapper stelemref) object:stelemref (object,intptr,object) DG.Tweening.Core.TweenManager.AddActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:731) DG.Tweening.Core.TweenManager.GetTweener[Color,Color,ColorOptions]() (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:97) DG.Tweening.DOTween.ApplyTo[Color,Color,ColorOptions](DG.Tweening.Core.DOGetter1 getter, DG.Tweening.Core.DOSetter1 setter, Color endValue, Single duration, DG.Tweening.Plugins.Core.ABSTweenPlugin3 plugin) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/DOTween.cs:879) DG.Tweening.DOTween.ToAlpha (DG.Tweening.Core.DOGetter1 getter, DG.Tweening.Core.DOSetter`1 setter, Single endValue, Single duration) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/DOTween.cs:404) DG.Tweening.ShortcutExtensions.DOFade (UnityEngine.UI.Image target, Single endValue, Single duration) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween46/ShortcutExtensions.cs:70) CCellArrowMap.setState (ECellArrowState st) (at Assets/Scripts/Objects/CCellArrowMap.cs:32) CCellArrowMap.Start () (at Assets/Scripts/Objects/CCellArrowMap.cs:63)

Demigiant commented 9 years ago

Hi,

This bug was also found by another user yesterday, and I just posted a fix. Could you test it out to be sure? You can find it attached to this post.

andrew-chewie commented 9 years ago

Thanks for the fast response. I've downloaded latest version, but this error is not solved. Maybe I can provide any additional info to help find the issue.

Regards, Andrew

andrew-chewie commented 9 years ago

Seams like it happens when target objects is null somewhere in Awake/Start. I thought that DOtween has internal check for null objects?

Demigiant commented 9 years ago

Ouch, I hoped it was solved.

DOTween does have a check for NULL objects (if safe mode is active), but not when a tween is created, in which case it assumes the target is not NULL. Still, it shouldn't generate an IndexOutOfRange exception.

Can you create a sample project that replicates this issue? That would be great, so I can check it out and fix it once and for all :)

theshked commented 9 years ago

Hi,

I don't have a sample project, but this would occur consistently for me after a call to DOTween.Clear() in code that restarts my app. Removing the call solved the issue.

Hope this helps figuring it out...

Cheers, Alon

Demigiant commented 9 years ago

Hi,

Thank you, that will help indeed. Can you also tell me on which version you are, so I can check it out consistently? You can see your DOTween version inside the Utility Panel.

Cheers, Daniele

theshked commented 9 years ago

I am now on v1.0.775, but this also occurred on the May 15th version, v1.0.720.

Xerios commented 9 years ago

Having the same issue with v1.0.830 ( and previous versions ),

IndexOutOfRangeException: Array index is out of range.
DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:833)
DG.Tweening.Core.TweenManager.FilteredOperation (OperationType operationType, FilterType filterType, System.Object id, Boolean optionalBool, Single optionalFloat, System.Object optionalObj, System.Object[] optionalArray) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:504)
DG.Tweening.DOTween.Complete (System.Object targetOrId, Boolean withCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/DOTween.cs:646)

https://github.com/Demigiant/dotween/blob/e3bf095de8e8c3453c0882cb4554bcea7dda5344/_DOTween.Assembly/DOTween/Core/TweenManager.cs#L833

This is what I'm getting after doing a DOTween.Complete("undoPulse"); or Kill function, even with DOTween.IsTweening("undoPulse") check I still get the error.

Maybe add a check to see if index isn't bigger than the length or if it hasn't been altered.

Note that recycle is activated for my code and I mostly use strings for Ids.

Xerios commented 9 years ago

I guess it's a capacity issue, use many tweens for a while ( not simultaneously ) and you'll get those kind of errors.

For instance setting SetCapacity to less than default 200, it will make my bug appear earlier ( note that my scene only has max 20 simultaneous tweens ). Not sure how this library handles capacity but something needs to be done.

Demigiant commented 9 years ago

Hey Xerios,

I'm still waiting for a sample project that replicates this issue. I tried many times, but I can't replicate it on my side. If you can do that please send it to me by attaching a link here: that would be great and would certainly lead me to finally fix this issue.

Xerios commented 9 years ago

I have hard time replicating it outside my project ( and it's also hard to reproduce inside my project ), clearly there's something I might be doing wrong.

Funny part is that it doesn't happen on the supposedly badly implemented tween, it actually happens on the next tween ( the error I mentioned previously came from another tween ), removing that tween I got this :

IndexOutOfRangeException: Array index is out of range.
DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:833)
DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:401)
DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50)

Note that safemode is active, and recycle is on.

I'll keep digging to see if I can find the issue or reproduce it properly.

Demigiant commented 9 years ago

Thank you. I know where the error ends, the thing I can't replicate either is how to make it happen in order to determine where it starts. I tried everything I could think of, sigh. Will cross my finger hoping you can reproduce it.

PeterDekkers commented 8 years ago

I'm experiencing this issue also, only when Recycling is on. When I turn recycling off it doesn't happen. Will see if I can reproduce...

PeterDekkers commented 8 years ago

This crazy code reproduces it using DOTween v1.1.260. Don't try this at home... ;)

using UnityEngine;
using System.Collections;
using DG.Tweening;

public class reproduce_dotween_bug : MonoBehaviour {

    const string TWEEN_ID = "abc";

    void Start () {

        // Enable recycling
        DOTween.Init(true).SetCapacity(500,250);

        // Start a bunch of tweens with the same ID and varying durations
        for (int i = 0; i < 250; i++) {
            NewTween();
        }

        // Kill+complete tweens every so often
        InvokeRepeating("KillAndComplete", 0, 0.5f);
    }

    void NewTween()
    {
        Vector3 myVector = Vector3.zero;
        // Each time this completes, start a new tween. This is crucial for bug reproduction.
        DOTween.To(()=> myVector, x=> myVector = x, Vector3.one, Random.Range(0.1f, 0.9f)).SetId(TWEEN_ID).SetAutoKill(true).Play().OnComplete(NewTween);
    }

    void KillAndComplete()
    {
        // Completing the tween is crucial for bug reproduction.
        DOTween.Kill(TWEEN_ID, true);
    }

}
Demigiant commented 8 years ago

Daaamn I thought this was finally solved, but you seem to have found another way to generate it. Great that you have the reproducible coding, so I can squash this more. Will get onto it asap.

Decavoid commented 8 years ago

This code reproduces the bug using only 2 sequence objects. Add this script on an empty GameObject.

using System;
using System.Collections;
using DG.Tweening;
using UnityEngine;

public class Test : MonoBehaviour
{
    private int killCounter = 0;

    private void Awake()
    {
        DOTween.Init(true, true, LogBehaviour.Verbose);
        DOTween.SetTweensCapacity(200, 125);
    }

    private void Start()
    {
        const float Delay = 2;
        DOTween.Sequence().AppendInterval(Delay).OnKill(OnKill);
        DOTween.Sequence().AppendInterval(Delay).OnKill(OnKill);
    }

    private void OnKill()
    {
        if (++killCounter == 2)
            StartCoroutine(Coroutine());
    }

    private IEnumerator Coroutine()
    {
        Sequence sequence = DOTween.Sequence().AppendInterval(2).OnKill(() => { });

        yield return new WaitForSeconds(1);

        Debug.Log("sequence.Kill()");
        sequence.Kill(); // IndexOutOfRangeException
    }
}
IndexOutOfRangeException: Array index is out of range.
DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at Assets/ThirdParty/DOTween/Core/TweenManager.cs:895)
DG.Tweening.Core.TweenManager.Despawn (DG.Tweening.Tween t, Boolean modifyActiveLists) (at Assets/ThirdParty/DOTween/Core/TweenManager.cs:203)
DG.Tweening.TweenExtensions.Kill (DG.Tweening.Tween t, Boolean complete) (at Assets/ThirdParty/DOTween/TweenExtensions.cs:135)
Test+<Co2>c__IteratorE0.MoveNext () (at Assets/Test.cs:36)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

In TweenManager.Update _KillList contains 2 sequences (id 0 and 1). Despawn is called on the first sequence (id 0). The first sequence is pushed to _PooledSequences. Despawn is called on the second sequence (id 1). onKill callback is called, that calls Coroutine coroutine, that launches third sequence popped from _PooledSequences. activeId is changed from 0 to 2. The second sequence is pushed to empty _PooledSequences. RemoveActiveTween(_KillList[1]) resets activeId of the second sequence from 1 to -1. RemoveActiveTween(_KillList[0]) resets activeId of the first = third sequence from 2 to -1. Killing the third sequence causes the IndexOutOfRangeException because activeId is -1.

Decavoid commented 8 years ago

I made a PR https://github.com/Demigiant/dotween/pull/99 that fixesIndexOutOfRangeException exception reproducible by the test case above.

fulviokidloom commented 8 years ago

Hi, I have the same issue when I run the app from an android device.. not from the pc. I haven't tested in iOS yet. The plugin in the store is already updated with this solution?

Thanks

Demigiant commented 8 years ago

Thank you very much @Andreyul!!! I was very busy trying to replace try-catch calls in the whole DOTween (because otherwise safe-mode will crash on UWP) so I didn't give this the right attention. I'm on it now, wait until the end of the day @fulviokidloom

Demigiant commented 8 years ago

Implemented the fix and uploaded to the website as v1.1.340. @Andreyul I modified your fix a little, but overall it's the same (and added you on the website's credits page :P). Thanks again!

Hitomilras commented 4 years ago

Have this issue with last version 1.2.335

IndexOutOfRangeException: Index was outside the bounds of the array. DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1090) DG.Tweening.Core.TweenManager.Despawn (DG.Tweening.Tween t, System.Boolean modifyActiveLists) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:236) DG.Tweening.Core.TweenManager.Complete (DG.Tweening.Tween t, System.Boolean modifyActiveLists, DG.Tweening.Core.Enums.UpdateMode updateMode) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:667) DG.Tweening.TweenExtensions.Kill (DG.Tweening.Tween t, System.Boolean complete) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/TweenExtensions.cs:125) CityScenario+ScenarioPart.Stop () (at Assets/Scripts/Scenarios/CityScenario.cs:143)

Demigiant commented 4 years ago

Ohnoes :( Do you have a way to reproduce this? That would help a lot. I solved every fringe case so I assume yours is some new fringe case that I can't replicate (just finding a way to replicate those was almost impossible) :B

Hitomilras commented 4 years ago

Ohnoes :( Do you have a way to reproduce this? That would help a lot. I solved every fringe case so I assume yours is some new fringe case that I can't replicate (just finding a way to replicate those was almost impossible) :B

I can just now go into skype with you, add you to my repository and find it)) alexey.notersdein is my skype.

I really need to fix this bug very quickly and if you can help - it will be very, very good :)

Demigiant commented 4 years ago

Ahoy! If you can reproduce it it would help me a lot, because I can't do it right now so I'll probably get to it tomorrow morning, sorry.

P.S. If it's urgent because of a release I can implement a quick "fail-check" system so you'll be good to go, but if you manage to replicate this and send me a barebone project that reproduces it that would help a lot to stifle the real reason why this is happening.

Demigiant commented 4 years ago

As a hint, look into the places where you use DOTween.Clear, because all the past fringe cases were usually about that, so maybe that's the case this time too. Otherwise for cases where you kill tweens in "weird" moments. P.S. Also, you don't need DOTween.Clear, DOTween.KillAll is more than enough ;)

Hitomilras commented 4 years ago

There is no DOTween.Clear and recycling is disabled.

So, project is written really badly, and because of urgent release, i was one who was choosen to refactor this in 2 days.

Inside project previous developer used really A LOT of tweens and in OnComplete callbacks lots of tweens create new tweens, and so on. Tweens create more tweens on complete and this tweens create even more tweens as they are complete.

Error occuring in function Tween.Kill(true).

I can send you this sources to check it, but this 'code' is really a stress test for DOTween as y system :) I didn't see such a bad code previously, i think)

Demigiant commented 4 years ago

Mhmm ok if the project is that messed I see it would probably take me all day to find the issue, and I can't spend all day on that today. But let's try it. Who knows maybe I will be lucky. Please share the project with me and tell me in as detailed a way as possible how to reproduce this bug in said project. If I can't find it within today then tomorrow I will implement the quick safety check. (Write me at myname.mysurname@google'smail.com, or just write here and I'll reply with my full mail :P)

antonysze commented 4 years ago

I'm now using v1.2.305. I got out of range exception from 2 methods which logged by Firebase Crashlytics in production build. Following are the exception logged:

Non-fatal Exception: java.lang.Exception: IndexOutOfRangeException : Index was outside the bounds of the array.
       at DG.Tweening.Core.TweenManager.ReorganizeActiveTweens(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.TweenManager.Update(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.DOTweenComponent.Update(DG.Tweening.Core.DOTweenComponent)
Non-fatal Exception: java.lang.Exception: IndexOutOfRangeException : Index was outside the bounds of the array.
       at DG.Tweening.Core.TweenManager.RemoveActiveTween(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.TweenManager.Despawn(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.TweenManager.DespawnActiveTweens(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.TweenManager.Update(DG.Tweening.Core.TweenManager)
       at DG.Tweening.Core.DOTweenComponent.Update(DG.Tweening.Core.DOTweenComponent)

They are different from Hitomilras's. But those exception seems caused by incorrect t.activeId in TweenManager.RemoveActiveTween by

int index = t.activeId;

I afraid that activeId is set to -1 incorrectly and it is used for index of array.

However, I cannot reproduce this problem locally. I cannot find a way to debug or even find out where does it cause the problem from my code. I would like to ask for debugging tips on this issue like custom logging or something else to find out the problem.

Whyser commented 4 years ago

Having same issue but I'm using DOTween v1.1.660 (a bit scared to upgrade because project is already Live). From Crashlytics (15 users):

Non-fatal Exception: java.lang.Exception IndexOutOfRangeException : Index was outside the bounds of the array. DG.Tweening.Core.TweenManager.ReorganizeActiveTweens (DG.Tweening.Core.TweenManager) DG.Tweening.Core.TweenManager.AddActiveTween (DG.Tweening.Core.TweenManager) DG.Tweening.Core.TweenManager.GetTweener[T1,T2,TPlugOptions] (DG.Tweening.Core.TweenManager) DG.Tweening.DOTween.ApplyTo[T1,T2,TPlugOptions] (DG.Tweening.DOTween) DG.Tweening.DOTween.To (DG.Tweening.DOTween) DG.Tweening.ShortcutExtensions.DORotate (DG.Tweening.ShortcutExtensions)

Has further improvement to this issue been done since v1.1.340 (mentioned above)?

DeRvinBy commented 2 years ago

We get the same exceptions from users from Firebase Crashlytics , and accidentally managed to reproduce it in the project

My Unity Log:

[Exception] NullReferenceException: Object reference not set to an instance of an object
DOTweenModuleUI+<>c__DisplayClass4_0.<DOFade>b__0()    Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs:79
77:   public static TweenerCore<Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration)
78:   {
-->79:       TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
80:       t.SetTarget(target);
81:       return t;

Tweener.DoStartup[T1,T2,TPlugOptions]()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tweener.cs:157

DG.Tweening.Core.TweenerCore`3[T1,T2,TPlugOptions].Startup()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:250

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:533

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:417

DOTweenComponent.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75
[Exception] NullReferenceException: Object reference not set to an instance of an object
DOTweenModuleUI+<>c__DisplayClass4_0.<DOFade>b__0()    Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs:79
77:   public static TweenerCore<Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration)
78:   {
-->79:       TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration);
80:       t.SetTarget(target);
81:       return t;

ColorPlugin.EvaluateAndApply()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Plugins/ColorPlugin.cs:89

DG.Tweening.Core.TweenerCore`3[T1,T2,TPlugOptions].ApplyTween()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:273

Tween.DoGoto()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:266

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:569

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:417

DOTweenComponent.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75

I checked the calling code, and indeed, null is passed in the "target" argument. But then a log is output with an exception that is reproduced from users from Firebase Crashlytics.

[Exception] IndexOutOfRangeException: Index was outside the bounds of the array.
TweenManager.RemoveActiveTween()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1164

TweenManager.Despawn()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:236

TweenManager.DespawnActiveTweens()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1150

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:496

DOTweenComponent.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75
[Exception] IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
TweenManager.ReorganizeActiveTweens()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1140

TweenManager.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:404

DOTweenComponent.Update()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75

Then the following log is output, but I think there is an exception due to the above NullReferenceException

[Exception] IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
TweenManager.ReorganizeActiveTweens()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1140

TweenManager.AddActiveTween()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1073

TweenManager.GetSequence()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:146

DOTween.Sequence()    D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/DOTween.cs:707

PulseImageEffect.Update()    Assets/Scripts/Views/Effects/PulseImageEffect.cs:30
28:   if (_currentPulseDelay < 0) {
29:       var pulseView = GetPulseView();
-->30:       DOTween.Sequence().Append(pulseView.DOFade(0, pulseDuration))
31:           .Join(((RectTransform) pulseView.transform).DOSizeDelta(_viewSize * maxScale, pulseDuration))
32:           .SetId(this)

However, in Firebase Crashlytics we did not find the above Null Reference exceptions, only IndexOutOfRange exceptions. I would like to know if the exceptions from Firebase Crashlytics can be related to those that were reproduced in the project. And as I understand it, these exceptions are reproduced when exceptions occur in the use of animation. So should they be handled or is this standard behaviour and we need to look for similar calls that cause an exceptions from Firebase Crashlytics?

I use DOTween with version 1.2.632 and Unity with version 2020.3.25.f1. And I don't use DOTween Safe Mode.

rfadeev commented 2 years ago

@DeRvinBy If the exceptions are reproducible, would it be possible to create and share sample project with the reproduction case? I know sharing the original project is impossible, but guaranteed way to reproduce the issue would help immensely. The project I worked on before never managed to get stable reproduction case.

DeRvinBy commented 2 years ago

@rfadeev Yes, I managed to reproduce it in a separate project. Attach a link to Project. To reproduce the exception, you need to press the E key several times.

Demigiant commented 2 years ago

Ahoy! The error above seems indeed related to your tween's target becoming NULL while the tween is playing, which, without safe mode enabled, will cause general failures (in these cases I recommend to at least enable safe mode + debug mode to find the culprit easily, then fix it and eventually disable safe mode again). I'm downloading the project to check it out anyway.

Demigiant commented 2 years ago

Tested and yes, the issue is simply the target being NULL and causing a nullref exception, which interrupts the flow and causes loads of problems in DOTween, including later indexOutOfRange exceptions. Enabling safe mode fixes this on the fly because in that case DOTween captures the NULL ref and immediately deletes the tween without interrupting the flow.

Whyser commented 2 years ago

I think it's wise to point out (which I think Demigiant almost did, by saying "disable safe mode again") that Safe Mode is safe in the way that it doesn't throw/cause exceptions. But keep in mind, things will usually NOT behave as expected if issues occur even while in Safe Mode. Safe mode is just a dirty bandage and in my experience should not be used in production apps. :P

DeRvinBy commented 2 years ago

As I expected, the IndexOutOfRange exception occurs due to errors with calling DO Tween methods. So we have to fix them so that the IndexOutOfRange exceptions disappear from Firebase Crashlytics. Thanks a lot.

ExoRivas commented 2 years ago

Here the same problem, it happens to me specifically with a doScale call and then releases all the trace that the rest of the users show, someone with the same problem?

rhys-vdw commented 2 years ago

I'm hitting this now.

IndexOutOfRangeException: Index was outside the bounds of the array.
DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1181)
DG.Tweening.Core.TweenManager.Despawn (DG.Tweening.Tween t, System.Boolean modifyActiveLists) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:236)
DG.Tweening.TweenExtensions.Kill (DG.Tweening.Tween t, System.Boolean complete) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/TweenExtensions.cs:143)
EffortStar.ActorHealthBar.SetValueImmediate (System.Int32 value) (at Assets/_Game/Scripts/UI/ActorHealthBar.cs:118)
EffortStar.ActorHealthBar.StopInspect () (at Assets/_Game/Scripts/UI/ActorHealthBar.cs:112)
EffortStar.ActorHealthBarUi.StopInspect (Leopotam.EcsLite.EcsPackedEntity entity) (at Assets/_Game/Scripts/UI/ActorHealthBarUi.cs:112)
EffortStar.GameManager.ClearHighlight () (at Assets/_Game/Scripts/GameManager.cs:637)
EffortStar.GameManager.Update () (at Assets/_Game/Scripts/GameManager.cs:837)

IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
DG.Tweening.Core.TweenManager.ReorganizeActiveTweens () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:1157)
DG.Tweening.Core.TweenManager.Update (DG.Tweening.UpdateType updateType, System.Single deltaTime, System.Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:404)
DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75)

It's on a call of _tween.Kill(false); on a sequence tween.

We're on version 1.2.705

TheAnosmic commented 2 years ago

I just had this issue today with the latest version. In our case, it was the combination with UniTask, with this code: t.ToUniTask(TweenCancelBehaviour.KillAndCancelAwait... that caused the t.Kill(false) function to free the current running "Thread" of UniTask, then another "Thread" called Kill() again on the same tween.

rhys-vdw commented 1 year ago

Ah yes, I'm using UniTask too. This is likely the case here. The tween was likely being awaited while it was killed, and possible that the awaiter fired a cancellation token resulting in a double kill. I haven't seen this issue crop up again though.

HiGame commented 9 months ago

@Demigiant

"Dear Demigiant , it seems I've encountered this issue as well; it occurs on Android devices but so far, I haven't experienced it on PC. Could you please advise on how to resolve this? Thank you!"

dotween: v1.2.740

1 2

chanon commented 1 month ago

I'm getting this error reported on end-user devices but can't replicate it myself.

I am also using UniTask, but I am unable to pinpoint the cause. My stacktrace points to it happening when I call Kill() on a sequence inside a component OnDestroy() method.

How can I prevent this error or do a check before calling Kill()?

Also, I'm not sure, but this seems to have started since I updated to the latest DOTween version. I might try reverting to the previous version.