MoDDiB / dotween

Automatically exported from code.google.com/p/dotween
0 stars 0 forks source link

Out Of Memory in Tween(] resize #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I'm using Dotween 1.0.035

What steps will reproduce the problem?
1. A game object with a script using tween
2. Play mode active, tween playing
3. Activate debug view in inpector

Exception :

OutOfMemoryException: Out of memory
System.Array.Resize[Tween] (DG.Tweening.Tween[]& array, Int32 length, Int32 
newSize) (at 
/Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/Sy
stem/Array.cs:1928)
System.Array.Resize[Tween] (DG.Tweening.Tween[]& array, Int32 newSize) (at 
/Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/Sy
stem/Array.cs:1912)
DG.Tweening.Core.TweenManager.IncreaseCapacities (CapacityIncreaseMode 
increaseMode) (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Tween
Manager.cs:761)
DG.Tweening.Core.TweenManager.GetTweener[Single,Single,FloatOptions] () (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Tween
Manager.cs:89)
DG.Tweening.DOTween.ApplyTo[Single,Single,FloatOptions] 
(DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Single 
endValue, Single duration, DG.Tweening.Plugins.Core.ABSTweenPlugin`3 plugin) 
(at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs
:785)
DG.Tweening.DOTween.To (DG.Tweening.Core.DOGetter`1 getter, 
DG.Tweening.Core.DOSetter`1 setter, Single endValue, Single duration) (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs
:228)
DG.Tweening.ShortcutExtensions.DOIntensity (UnityEngine.Light target, Single 
endValue, Single duration) (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/ShortcutEx
tensions.cs:125)
LightningRelay.IdleLight () (at Assets/Game/Scenery/Electricity/Lightning 
Relay/LightningRelay.cs:142)
DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 
toCompletedLoops, UpdateMode updateMode) (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Tween.cs:2
38)
DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, 
Single independentTime) (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Tween
Manager.cs:376)
DG.Tweening.Core.DOTweenComponent.Update () (at 
D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/DOTwe
enComponent.cs:49)

Dotween creates zillion of tweens without destroying them.

Original issue reported on code.google.com by sgl...@gmail.com on 23 Jan 2015 at 7:59

Attachments:

GoogleCodeExporter commented 8 years ago
Hello,

DOTween doesn't create tweens by itself: each tween is created manually via one 
of your scripts. I imagine you're creating tweens inside an Update call at 
every frame, thus generating tons of them? Can you show me the code you're 
using?

Original comment by daniele....@gmail.com on 23 Jan 2015 at 8:21

GoogleCodeExporter commented 8 years ago
Le 23/01/2015 21:21, dotween@googlecode.com a écrit :

Hello,

Agree with what you say, but the tweens are not called in update (only 
for the first call) then call themselves using OnComplete().
Everything works perfectly, until I active DebugMode. By the way if 
Debug is active before playing and then I switch to Normal while 
playing, the same problem appears.

Before entering Update(), the variable Status is set to 
RelayStatus.SetIdling.

     public void Update()
     {
         switch (Status)
         {
case RelayStatus.SetIdling:
                 IdlePosition();
                 IdleLight();
                 Status = RelayStatus.Connected;
                 break;
             case RelayStatus.Connected:
                 break;
             case RelayStatus.Disconnecting:
                 break;
         }
     }

     /// <summary>
     /// Change light intensity while idling
     /// </summary>
     private void IdleLight()
     {
         Light.DOIntensity(Random.Range(LightMin, LightMax), 
0.1f).OnComplete(IdleLight);
     }

     /// <summary>
     /// Move relay while idling
     /// </summary>
     private void IdlePosition()
     {
         // Calculate default position for  relay
         var RelayPos = new Vector3
                             {
                                 x = 
_MasterConnection.GameObject.transform.position.x < transform.position.x 
? _MasterConnection.GameObject.transform.position.x +                 
                  MaxSourceDistance : 
_MasterConnection.GameObject.transform.position.x - MaxSourceDistance,
                                 y = _SlaveConnection.GameObject == null
                                         ? 
_MasterConnection.GameObject.transform.position.y
                                         : 
(_MasterConnection.GameObject.transform.position.y + 
_SlaveConnection.GameObject.transform.position.y) / 2,
                                 z = transform.position.z
                             };

         // Randomize in idling rect
         var NewPos = RelayPos
                     + new Vector3(
                         Random.Range(IdlingRect.min.x, IdlingRect.max.x),
                         Random.Range(IdlingRect.min.y, IdlingRect.max.y),
                         0);

         transform.DOMove(NewPos, 
2).OnComplete(IdlePosition).SetEase(Ease.OutBack);
     }

Original comment by sgl...@gmail.com on 23 Jan 2015 at 8:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I've bypassed the issue by restarting the tweens during update() call.

Original comment by sgl...@gmail.com on 23 Jan 2015 at 9:16

GoogleCodeExporter commented 8 years ago
Oh I get it now.

Restarting the tween is surely a better solution (but even better would be to 
just set the same one to loop indefinitely using SetLoops, if I understand 
correctly your usecase).

Still, I managed to replicate your issue and it's actually a bug (which happens 
if you create a tween during an OnComplete of a very short-timed tween). I 
fixed it in the version you find attached :)

Original comment by daniele....@gmail.com on 23 Jan 2015 at 11:42

Attachments:

GoogleCodeExporter commented 8 years ago
Perfect! The bug is corrected.
I can't use SetLoops because the Tween values are changed at each call.

Original comment by sgl...@gmail.com on 24 Jan 2015 at 9:57