Skip to content

Switch to MutationObserver#198

Merged
briancavalier merged 2 commits intodevfrom
mutation-observer
Sep 23, 2013
Merged

Switch to MutationObserver#198
briancavalier merged 2 commits intodevfrom
mutation-observer

Conversation

@briancavalier
Copy link
Member

This drops setImmediate and MessageChannel support, relying primarily on process.nextTick for all Node versions, and adding MutationObserver support as the "fast" browser scheduler. Vert.x support is unchanged, and everything falls back to setTimeout when no fast option is detected.

Definitely looking for feedback.

Fix #197

…eChannel in favor of MutationObserver. This forces falling back to setTimeout in IE < 11, and Safari < 6 (see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver#Browser_compatibility).
when.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

So this works multiple times? The 'x' attribute doesn't have to change its value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently, yeah. I've run some tests in Chrome and it works. I plan to let Travis run the full gamut of tests on all platforms when this lands in dev as well. Also, this is how RSVP implements it

…hat it is still a problem, we can add it back easily enough. The webkit ticket appears to have been closed quite a while ago: Jan 2013.
@briancavalier
Copy link
Member Author

Ok, I slimmed the MO branch down by removing the unload workaround.

@briancavalier
Copy link
Member Author

A couple nice benefits of this approach:

  1. It cuts the time-to-first-handler in half on Chrome 29 (haven't tested on other recent chromes)
  2. It reduces that time by about 25% on FF 24, and stabilizes it. We were falling back to setTimeout on FF, which is notoriously inconsistent.

One obvious downside:

  1. It forces IE10 to fall back to setTimeout. Only way to deal with this for now would be to introduce a postMessage or other additional hack.

@unscriptable
Copy link
Member

Combination of IE10 mobile + setTimeout concerns me.

@briancavalier
Copy link
Member Author

Merging after more discussion with @unscriptable, and in light of the fact that postMessage suffers the same problem. I'm ok with IE10 getting setTimeout. If we discover that either onreadystatechange or requestAnimationFrame is somehow a better alternative, we can consider introducing one of them.

briancavalier added a commit that referenced this pull request Sep 23, 2013
Switch to MutationObserver to workaround IE10 setImmediate/MessageChannel/postMessage bug
@briancavalier briancavalier merged commit 00ed267 into dev Sep 23, 2013
@briancavalier
Copy link
Member Author

All green on Travis and Saucelabs tests. At least we know we haven't broken the world :)

@stefanpenner
Copy link

👍

@briancavalier briancavalier deleted the mutation-observer branch March 26, 2014 19:02
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