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

add limit to getDuration() in spring function to avoid infinite loops #767

Closed
wants to merge 1 commit into from

Conversation

okikio
Copy link
Contributor

@okikio okikio commented Jun 29, 2021

The way the getDuration() method in the spring() function is setup it doesn't have any way of stopping an infinite loop. I added a INTINITE_LOOP_LIMIT of 10,000 to stop possible infinite loop situations.

@RafaelKr
Copy link

Shouldn't this be named INFINITE_LOOP_LIMIT (with an f instead of t)?

@RafaelKr
Copy link

Also maybe it would be an idea to use Number.MAX_SAFE_INTEGER instead of 10,000?

@luni-moon
Copy link

luni-moon commented Jan 17, 2022

I think there are times people would want an infinite loop though...

(Like if you had a terminal blinking, it could blink the underscore infinitely...)

Screen.recording.2022-01-17.12.20.52.PM.mp4

@okikio
Copy link
Contributor Author

okikio commented Jan 17, 2022

While calculating the spring easing, the for loop can sometimes encounter infinite loops that cause the browser to freeze, I've run into this problem a couple times. I choose 10,000 because it was the value that allowed for the most accurate spring easings while avoiding the browser freezing for extended periods of time.

@luni-moon
Copy link

While calculating the spring the for loop can sometimes encounter infinite loops, that cause the browser to freeze, I've run into this problem a couple times.

That is true, but I hope there is an alternative method added, to allow things like my example, to work.

@okikio
Copy link
Contributor Author

okikio commented Jan 17, 2022

While calculating the spring the for loop can sometimes encounter infinite loops, that cause the browser to freeze, I've run into this problem a couple times.

That is true, but I hope there is an alternative method added, to allow things like my example, to work.

What you're looking for is different from what this pr is aiming to fix, but yeah I agree with you, it would be cool if animejs supported blinking animation

@luni-moon
Copy link

While calculating the spring the for loop can sometimes encounter infinite loops, that cause the browser to freeze, I've run into this problem a couple times.

That is true, but I hope there is an alternative method added, to allow things like my example, to work.

What you're looking for is different from what this pr is aiming to fix, but yeah I agree with you, it would be cool if animejs supported blinking animation

Yeah, just making sure it doesn't break what I am using it for lol.

@RafaelKr
Copy link

While calculating the spring easing, the for loop can sometimes encounter infinite loops that cause the browser to freeze, I've run into this problem a couple times. I choose 10,000 because it was the value that allowed for the most accurate spring easings while avoiding the browser freezing for extended periods of time.

Could you post the code which freezes the browser please? Maybe there's another solution to the problem.

@okikio
Copy link
Contributor Author

okikio commented Jan 17, 2022

@RafaelKr There was something wrong with this pr, it seems the branch repo the changes were located in were deleted, so, I had to recreate a new pr. The new pr is #798, I'll close this one, we can continue our conversation there.

@okikio okikio closed this Jan 17, 2022
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.

3 participants