Demigiant / dotween

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

IndexOutOfRangeException: Array index is out of range. #278

Closed thienhaflash closed 5 years ago

thienhaflash commented 5 years ago

I saw lots of crash due to Array index out of range, please double check, we are using DOTween v1.2.135

Here is the managed stack trace from Unity crash report. Please ping me if you need more information

Managed Stack Trace:

(wrapper stelemref) object:stelemref (object,intptr,object)
DG.Tweening.Core.TweenManager.AddActiveTween (DG.Tweening.Tween t)
DG.Tweening.Core.TweenManager.GetTweener[Vector3,Vector3,VectorOptions] ()
DG.Tweening.DOTween.ApplyTo[Vector3,Vector3,VectorOptions] (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Vector3 endValue, Single duration, DG.Tweening.Plugins.Core.ABSTweenPlugin`3 plugin)
DG.Tweening.DOTween.To (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Vector3 endValue, Single duration)
DG.Tweening.ShortcutExtensions.DOScale (UnityEngine.Transform target, Single endValue, Single duration)
starEffect.startEffect ()
starEffect.OnEnable ()
thienhaflash commented 5 years ago

How and when will all this errors be fixed?

MissingReferenceException: The object of type 'RectTransform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.Transform.set_localScale (Vector3 value) DG.Tweening.ShortcutExtensions+<>c__DisplayClass40_0.<DOScale>b__1 (Vector3 x) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/ShortcutExtensions.cs:506) DG.Tweening.Plugins.Vector3Plugin.EvaluateAndApply (VectorOptions options, DG.Tweening.Tween t, Boolean isRelative, DG.Tweening.Core.DOGetter1 getter, DG.Tweening.Core.DOSetter1 setter, Single elapsed, Vector3 startValue, Vector3 changeValue, Single duration, Boolean usingInversePosition, UpdateNotice updateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs:121) DG.Tweening.Core.TweenerCore3[UnityEngine.Vector3,UnityEngine.Vector3,DG.Tweening.Plugins.Options.VectorOptions].ApplyTween (Single prevPosition, Int32 prevCompletedLoops, Int32 newCompletedSteps, Boolean useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:184) DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 toCompletedLoops, UpdateMode updateMode) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Tween.cs:252) 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:450) DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:71)


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:955) DG.Tweening.Core.TweenManager.Despawn (DG.Tweening.Tween t, Boolean modifyActiveLists) (at D:/DG/_Develop/UNITY3_CLASSES/_Holoville/DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:231) DG.Tweening.Core.TweenManager.DespawnActiveTweens (System.Collections.Generic.List1 tweens) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:943) 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:462) DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:71)

Demigiant commented 5 years ago

Sorry, completely missed the first message. But now that I see the second, the "MissingReferenceException" is the reason. You are running a tween on a RectTransform that has been destroyed, which will cause all types of errors everywhere. You should either activate safe mode or take care to kill tweens for the objects that you destroy. Let me know.

thienhaflash commented 5 years ago

That's actually not the case, I did a tween with some delay, then the scene got unload and everything is being destroyed. I think you need to check null before trying to modify values of tween targets.

Please read the stack tracing I sent you before

I have no way to fix it from my side, so please help! If you need any other input from me don't hesitate to ask, I'm on skype at thienhaflash

I also got hundred thousands of crash report related to DOTween everyday (our game has user based of 200M and DAU is about 300-400K) so it's kind of urgent in our side, If there are anything I can do to speed up the fix, please don't hesitate to tell!

Thanks a lot!

Demigiant commented 5 years ago

For the first one, the nullref, I'm afraid it's on your side. Let me explain.

Tweens don't have a target (other than a custom property that one can manually set for convenience), since they can work on any object and storing a general object type for operations would be inefficient (this logic is valid for any good tween engine in any language I ever saw). They just store a getter and a setter to the property they're tweening. Thus it's your responsibility to kill tweens before their actual target is destroyed (see A Tween's Life here). Alternatively, as I mentioned, you can activate safe mode, which takes care of any such errors.

For the second one, the index-out-of-range, that sounds like a very rare error that happens only in fringe uses of DOTween, which I should've squashed completely, but maybe you're doing something weird that I never thought of. First of all, I would recommend to fix the nullref one, which could very well cause the index-out-of-range one. If that isn't fixed, it would really help if you could give me information on the tweens causing it (try to find something weird in your code usage, that should be it).

Demigiant commented 5 years ago

P.S. wrote you on skype too

Demigiant commented 5 years ago

Pushed another fix for this so it should be completely solved. Marking it as closed.