luobin82Robin / dotween

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

Tween sometimes getting freezed #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Tween sometimes getting freezed or maybe never executed. I'm expecting an 
OnComplete call and never getting it.
I've tried but failed to replicate the problem outside my project, I'm sure 
it's something related with DOTween.
I'm using verision 0.7.225

More details:

I'm using a small class I've made to create something like an Invoke but 
outside a MonoBehaviour class, I'ts based on DOTween.
I'm attaching the code to this report.
Using a breakpoint I found insteresting null values inside the failed Tween 
instance, I'm attaching screen captures with the data.

Original issue reported on code.google.com by fer...@gmail.com on 10 Aug 2014 at 10:18

Attachments:

GoogleCodeExporter commented 9 years ago
Replacing the call to my class with Invoke solves the problem so I'm sure this 
is DOTween related.

Original comment by fer...@gmail.com on 10 Aug 2014 at 10:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
getter, setter and id are null, that sounds like something is wrong, maybe if 
you can tell me what could cause that I can see why I'm not being able to 
replicate it in an empty project.

Original comment by fer...@gmail.com on 10 Aug 2014 at 10:25

GoogleCodeExporter commented 9 years ago
I tried replicating this issue in various ways but couldn't. The reasons why a 
Tweener's getter/setter might be null are:
- The tween is at the beginning of its instantion/spawning
- The tween has been killed
- You tween target got destroyed

I'm thinking maybe you're passing some special values to the DelayedCall 
method? Can you check what values you're passing when it hangs?

Also, could you try chaining on OnStart to see if at least it starts? Like this:
Tweener = DOTween.To(() => MilisecondsToCallLeft, s => MilisecondsToCallLeft = 
s, 0f, milisecondsToCall / 1000).
  SetEase(Ease.Linear).
  OnComplete(action).
  OnStart(()=> Debug.Log("DelayedCall Started));

Original comment by daniele....@gmail.com on 11 Aug 2014 at 7:46

GoogleCodeExporter commented 9 years ago
P.S. forgot to mention that id being null is ok instead (it's set manually with 
SetId or automatically when using shortcuts, which is not your case).

Original comment by daniele....@gmail.com on 11 Aug 2014 at 7:47

GoogleCodeExporter commented 9 years ago
OnStart is never getting called, this is what I did:

Tweener = DOTween.To(() => MilisecondsToCallLeft, s => MilisecondsToCallLeft = 
s, 0f, milisecondsToCall / 1000).
            SetEase(Ease.Linear).
            OnStart(()=>Debug.Log("Started")).
            OnComplete(action);
        Debug.Log("Created");

I'm attaching a screen capture of the console results

Original comment by fer...@gmail.com on 11 Aug 2014 at 6:48

Attachments:

GoogleCodeExporter commented 9 years ago
That's a typo in your first phrase I suppose? It seems like OnStart is getting 
called instead, which is good. Something must be un-triggering the OnComplete 
then. Can you try one more test and show me the logs again, to see if I can 
pinpoint it better? Substitute your tween with this one (I just changed the 
OnComplete, which now logs a message and only then calls the action):

Tweener = DOTween.To(() => MilisecondsToCallLeft, s => MilisecondsToCallLeft = 
s, 0f, milisecondsToCall / 1000).
  SetEase(Ease.Linear).
  OnStart(()=>Debug.Log("Started")).
  OnComplete(()=> {
    Debug.Log("Completed");
    action();
  });
Debug.Log("Created");

P.S. and sorry for my typos in the previous messages: it's a crazy day today

Original comment by daniele....@gmail.com on 11 Aug 2014 at 6:58

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
OnStart it's not being called, the screenshot shows 46 creations and 45 
Started, there is 1 OnStart never called.

Original comment by fer...@gmail.com on 11 Aug 2014 at 7:18

GoogleCodeExporter commented 9 years ago
The failed Tween instance values:

Time: 1.3f
Current value of the property to change: 1300f
Target value: 0f

Those numbers are the same passed to the other tweens where OnStart gets called 
and work fine. This seems to be random.

Original comment by fer...@gmail.com on 11 Aug 2014 at 7:35

GoogleCodeExporter commented 9 years ago
Changed MilisecondsToCallLeft type to int in the class posted here and the 
problem is gone, so is something releted with the float type

Original comment by fer...@gmail.com on 11 Aug 2014 at 7:41

GoogleCodeExporter commented 9 years ago
Superweird! Gonna check if it's related to the FloatPlugin then: great that you 
managed to pinpoint it, even if right now I have no idea why the int change 
changed everything.

By the way, OnStart is called the frame after you create the tween (since it's 
the first time DOTween verifies a tween is playing and actually changes the 
target's values), so that last one not being called is normal, if you 
paused/stopped it between the creation and the next frame. Or you didn't? With 
the int change all OnStart are called, and also all OnComplete?

Original comment by daniele....@gmail.com on 11 Aug 2014 at 9:15

GoogleCodeExporter commented 9 years ago
Yes, with the int change all OnStart are called and all OnComplete as well. 

The order of the problem is random, last time I checked was the 5th tween 
creation the one that never called OnStart.

Original comment by fer...@gmail.com on 11 Aug 2014 at 9:43

GoogleCodeExporter commented 9 years ago
Ok I got more clues: 
My game creates a DOTween to move the character before executing the series of 
DelayedCall instances that contains the DOTween that fails. If I change stuff 
in the character walk tween then the problem of the DelayedCall is gone, so 
this is being caused by other problematic DOTween executed.
I'll keep you updated with this.

Original comment by fer...@gmail.com on 11 Aug 2014 at 10:45

GoogleCodeExporter commented 9 years ago
I've found more dificult to reproduce DOTween bugs, I'm attaching a striped 
version of my project so you can debug it yourself, it's a Unity project.

1) Open the project in Unity with the scene located at: 
Assets\Scenes\Tests\Level Build Test.unity

2) Open the following script: 
Assets\Scripts\Character\WalkControllers\DirectionBasedWalkController.cs

3) Go to the TweenTo function, there you have code blocks commented and a line 
on each of them explaining the bug that each of them fires.

4) Open Assets\Scripts\Test1.cs There you have a DelayedCall test that executes 
when you run the game.

To test the DelayedCall bug just run the game, and before the test finishes 
walk pressing the arrow keys and watch the test in the console show the amount 
of OnStart not being called.

Original comment by fer...@gmail.com on 12 Aug 2014 at 1:21

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the debug project fermmm (by the way, I just realized you have 4 
Ms on Unity forums and only 3 here - mhmmm there's a mystery!). I'm gonna check 
it out now.

Original comment by daniele....@gmail.com on 12 Aug 2014 at 7:51

GoogleCodeExporter commented 9 years ago
Whew, this took me a long time to solve.

First of all, the latest update fixes DOMoveX/Y not working correctly with 
SetSpeedBased: http://dotween.demigiant.com/download.php

About OnComplete not being called, the reason is in your code instead, in the 
StopWalkTween method. Due to DOTween's recycling nature, you should always set 
a tween reference to NULL after you kill it. Otherwise, if you check if it's 
active the result might be TRUE even if the tween you intend to check was 
killed. That's because, after being killed, that same tween object might now be 
reused by another completely different tween.

About this last point, I understand it might be confusing, and I'll see if I 
can add another layer of pointers to force a tween reference to become null 
once it's been killed.

Original comment by daniele....@gmail.com on 12 Aug 2014 at 9:55

GoogleCodeExporter commented 9 years ago
Thanks for the fix, that reuse problem is very confusing and took me 2 days of 
test to figure out what was happening, you should solve it in a maximum 
priority, I'll open a new bug report for that one.

Original comment by fer...@gmail.com on 12 Aug 2014 at 4:45