Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxTimerManager: fix array manipulation in onComplete #1954

Merged
merged 6 commits into from
Sep 19, 2016
Merged

Conversation

Beeblerox
Copy link
Member

I've made mistake in my previous PR (inserted while loop in wrong place).
This PR request also changes completeAll() method. Previous version of this method doesn't take into account the value of active property of timer. This could lead to infinite loop (maybe i'm wrong about this), because without check of active value it adds inactive timers to timersToFinish array, which won't finish (there is check in timer's update method).
And thus i have a question: Do we need to activate paused timers and force them to finish or should we complete only active timers. I could add some parameter to completeAll() which will be responsible for this behavior, like includeInactive:Bool = false

I've made mistake in my previous PR (inserted while loop in wrong place).
This PR request also changes `completeAll()` method. Previous version of this method doesn't take into account the value of `active` property of timer. This could lead to infinite loop (maybe i'm wrong about this), because without check of `active` value it adds inactive timers to `timersToFinish` array, which won't finish (there is check in timer's update method).
And thus i have a question: Do we need to activate paused timers and force them to finish or should we complete only active timers. I could add some parameter to `completeAll()` which will be responsible for this behavior, like `includeInactive:Bool = false`
@Gama11
Copy link
Member

Gama11 commented Sep 18, 2016

Do we need to activate paused timers and force them to finish

My first instinct is "no", that would seem a little counter-intuitive. completeAll() should behave just like things would behave if you fast-forward time enough for all timers to be completed. If a timer is not active, it can't be completed.

Does FlxTweenManager's completeAll() have the same issue?

@Gama11 Gama11 added the Bug label Sep 18, 2016
@Gama11 Gama11 added this to the 4.2.0 milestone Sep 18, 2016
@Beeblerox
Copy link
Member Author

@Gama11 ok, let's leave this behavior for timer manager.

About FlxTweenManager: it doesn't check value of active property, which is wrong in my opinion.
Plus it have different behavior: it just fast forwards time of all tweens and tween's complete callback is being called only once on the next frame (like said in docs) and tween is being removed from manager on the next frame as well (just like said in its documentation).

FlxTimers are being removed the same frame we call completeAll() and timer's complete callback is being called the same frame loopsLeft times.

@Beeblerox
Copy link
Member Author

Should we add check for tween's active value in FlxTweenManager's completeAll() method as well?

@Beeblerox
Copy link
Member Author

i don't understand why CI checks are failing

@Gama11
Copy link
Member

Gama11 commented Sep 18, 2016

No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself. - the unit tests are hanging again. Have you tried running them locally?

@Beeblerox
Copy link
Member Author

i'll try tomorrow

@Beeblerox
Copy link
Member Author

stupid question: how to run those unit tests?

@Gama11
Copy link
Member

Gama11 commented Sep 18, 2016

@Beeblerox
Copy link
Member Author

@Gama11 thanks!

Fixed by changing timer's `update()` method. 
But timer `onComplete` callback is called after timer's property `finished` is set to true (which seems logical to  me, this is similar to tween).
Beeblerox added a commit that referenced this pull request Sep 19, 2016
this patch adds check for tween's `active` value in `completeAll()` method od `FlxTweenManager` (just like in #1954)
I think that we shouldn't finish tween if it's inactive.
Should we add this check in tween's `update()` method as well (like in `FlxTimer` class)?
@Beeblerox
Copy link
Member Author

All checks are passing now

@@ -281,12 +309,35 @@ class FlxTimerManager extends FlxBasic
public function completeAll():Void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... Does completeAll() really need to be this complex? For tweens it's only 3 lines, this seems a little much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this doesn't really seem related to #679? Might be better to handle changes to completeAll() in a separate pull request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more complex because docs about these methods says different things:

  • in flxtween it says that onComplete callback is called only once
  • in flxtimer - onComplete callback will be called loopsLeft times.

With your change there is should be onLoopFinished() call, because timer's update() method had been changed and doesn't contain this logic anymore

@Gama11 Gama11 changed the title Another one try to fix issue #679 FlxTimerManager: fix array manipulation inside onComplete, closes #679 Sep 19, 2016
@Gama11 Gama11 changed the title FlxTimerManager: fix array manipulation inside onComplete, closes #679 FlxTimerManager: fix array manipulation in onComplete Sep 19, 2016
@Gama11 Gama11 merged commit b8b9331 into dev Sep 19, 2016
@Gama11 Gama11 deleted the Beeblerox-patch-1 branch September 19, 2016 09:43
Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this pull request Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants