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

Prevent tick() handler from being entered while already processing #126

Merged
merged 1 commit into from
Dec 22, 2015
Merged

Prevent tick() handler from being entered while already processing #126

merged 1 commit into from
Dec 22, 2015

Conversation

kanongil
Copy link
Contributor

The loose event coupling means that tick() can easily be called while processing a tick(). This can lead to all sorts of weird behavior.

I am aware of at least one case where this happens: When loading a key which has already been loaded, the onKeyLoaded callback is called synchronously while a tick is processing, triggering another tick().

@mangui
Copy link
Member

mangui commented Dec 10, 2015

or we should never call this.tick() directly, and trigger a setTimeout(this.tick, 0);instead.

@jsalaj
Copy link
Contributor

jsalaj commented Dec 11, 2015

Hi,
I have one question. When will be ticks greater then 1 (if (this.ticks > 1)) inside condition if (this.ticks === 1) ? :-)

@kanongil
Copy link
Contributor Author

@mangui Yes, that is a valid solution as well, though it won't discard extra tick() calls like my method.

@jsalaj It will increase when something in the doTick method calls tick() synchronously.

mangui added a commit that referenced this pull request Dec 22, 2015
Prevent tick() handler from being entered while already processing
@mangui mangui merged commit 3b0d310 into video-dev:master Dec 22, 2015
if (this.ticks === 1) {
this.doTick();
if (this.ticks > 1) {
setTimeout(this.tick, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kanongil how can this line of code ever be reached? (given that we never call doTick() directly, but only tick(), and that this is the only place where we increment the counter)

Copy link
Collaborator

Choose a reason for hiding this comment

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

haha i got it finally. this somehow was a bit tricky to get to me :D

johnBartos pushed a commit that referenced this pull request Jun 27, 2018
…hes the spec (1-15) and the range of position values fall within the 80% width that the spec suggests. (#126)

JW8-205
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.

None yet

4 participants