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

dart2js should not use windows.setTimeout with a delay of 0 to implement Future.immediate #8757

Closed
peter-ahe-google opened this issue Feb 25, 2013 · 9 comments

Comments

@peter-ahe-google
Copy link
Contributor

Using windows.setTimeout with a delay of 0 doesn't do what we expect, as the next timer event may occur much later.

MDN recommends using windows.postMessage, see https://developer.mozilla.org/en/docs/DOM/window.setTimeout#Minimum_delay_and_timeout_nesting

This poses another problem as whatever message is posted might confuse user code.

It looks like a better alternative is to use MessageChannel, or an iframe.

@DartBot
Copy link

DartBot commented Feb 25, 2013

This comment was originally written by @bp74


IE10 supports performance.setImmediate(..) which is not a standard yet and not supported by Chrome and Firefox. But it would be the perfect solution in the future.

@jmesserly
Copy link

Yeah, I think "window.setImmediate" in dart:html is what you want.

It will do the best thing that is available in the browser, in priority order:

  1. setImmediate
  2. mutation observers
  3. postmessage

(you can find the impl by searching for "_MicrotaskScheduler.best" under sdk/lib/html)

@peter-ahe-google
Copy link
Contributor Author

Thank you, John!

@kasperl
Copy link

kasperl commented Apr 22, 2013

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@floitschG
Copy link
Contributor

The code for microtasks doesn't use setTimeout anymore.

@kevmoo kevmoo removed the triaged label Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants