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

setTimeout is used as scheduler in latest Chrome #915

Closed
lextiz opened this issue Dec 15, 2015 · 17 comments
Closed

setTimeout is used as scheduler in latest Chrome #915

lextiz opened this issue Dec 15, 2015 · 17 comments

Comments

@lextiz
Copy link
Contributor

@lextiz lextiz commented Dec 15, 2015

Latest Chrome does not have window.navigator.standalone defined (see https://github.com/petkaantonov/bluebird/blob/master/src/schedule.js#L26) always has function chrome.loadTimes, because of this hasDevTools always returns true in Chrome. It looks like undesired behavior.

@lextiz lextiz changed the title setTimeout is used as scheduler in latest Chrome version setTimeout is used as scheduler in latest Chrome Dec 15, 2015
@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Dec 15, 2015

That part is inside a !..

The reason that navigator.standalone is there is documented 3 lines above.

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Dec 15, 2015

You're right http://jsfiddle.net/10o58rup/ - it seems to be using setTimeout.

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Dec 15, 2015

Hmm, ((typeof MutationObserver !== "undefined") && !(typeof window !== "undefined" && window.navigator && window.navigator.standalone)) evaluates to true in latest chrome. Odd...

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

Maybe it not the case when bluebird is loaded?

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Dec 15, 2015

Unlikely - http://jsfiddle.net/ufpLxvqn/

I think this is not a bug, bluebird resets the scheduler to setTimeout if you have the devtools open so async stack traces correctly work.

Can you try to reproduce with devtools closed?

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

Yes. Will update when finished.

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

I have reproduced this with debugger closed: closed all debugger instances, closed all chrome processes, opened jsfiddle link, I see setTimeout there. Do you see MutationObserver implementation instead?

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

I see that (typeof chrome !== "undefined" && chrome && typeof chrome.loadTimes === "function") evaluates to true when debugger tools are closed

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

What is your Chrome version? I have 47.0.2526.80 m.

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Dec 15, 2015

Devtools doesn't matter, it will still use normal scheduler. Just without trampoline.

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Dec 15, 2015

Petka step through the code, it uses the regular scheduled and then overrides it with setTimeout

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Dec 15, 2015

Can you link to line?

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 15, 2015

This is overriding:

schedule = function(fn) { setTimeout(fn, 0); };

It happens when hasDevTools returns true. In current version of Chrome it always returns true, because chrome.loadTimes is a function.

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Dec 15, 2015

Ah yes static scheduler like mutation observer cannot be used without trampoline

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Dec 15, 2015

This is because async stack traces work only when trampoline is not used, the detection only detects if it's chrome, not if DevTools are open or if async stack traces are enabled

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Dec 16, 2015

This can be fixed by using 2 mutationobservers to get: working devtools async stack traces,fast performing trampoline and latency not affected by tab inactivity. 👍 demo: https://jsfiddle.net/yu7tx5em/4/

@lextiz
Copy link
Contributor Author

@lextiz lextiz commented Dec 16, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants