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

setInterval and setTimeout overrides do not satisfy original contract #58

Merged
merged 1 commit into from Sep 27, 2011

Conversation

Projects
None yet
2 participants
@darwin
Contributor

darwin commented Jul 31, 2011

  1. both functions should return id of created timer, so it can be cancelled at later point

  2. host.setFrameControl wipes old timeouts and creates new ones, but invalidates original timer ids, which makes it impossible to cancel prior timers

    Imagine this scenario (this caused havoc of my setInterval code):

    1. user code calls setInterval, gets id1 back
    2. someone calls host.setFrameControl, this will cancel id1 and re-create it with id2 internally (with possibly hijacked delay)
    3. user code wants to cancel original interval, calls cancelInterval with id1, but there is no id1 anymore
    4. interval id2 is never canceled and keeps triggering code indefinitely

I'm not sure if my code is correct. But it fixed my issues after enabling gli.

setInterval and setTimeout overrides do not satisfy original contract
1. both functions should return id of created timer, so it can be cancelled at later point
2. host.setFrameControl wipes old timeouts and creates new ones, but invalidates original timer ids, which makes it impossible to cancel prior timers

  Imagine this scenario (this caused havoc of my setInterval code):
  1. user code calls setInterval, gets id1 back
  2. someone calls host.setFrameControl, this will cancel id1 and re-create it with id2 internally (with possibly hijacked delay)
  3. user code wants to cancel original interval, calls cancelInterval with id1, but there is no id1 anymore
  4. interval id2 is never canceled and keeps triggering code indefinitely

I'm not sure if my code is correct. But it fixed my issues after enabling gli.

benvanik added a commit that referenced this pull request Sep 27, 2011

Merge pull request #58 from darwin/master
setInterval and setTimeout overrides do not satisfy original contract

@benvanik benvanik merged commit 129f2b9 into benvanik:master Sep 27, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment