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

Comments

Projects
None yet
3 participants
@lextiz
Contributor

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 from setTimeout is used as scheduler in latest Chrome version to setTimeout is used as scheduler in latest Chrome Dec 15, 2015

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Dec 15, 2015

Collaborator

That part is inside a !..

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

Collaborator

benjamingr commented Dec 15, 2015

That part is inside a !..

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

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Dec 15, 2015

Collaborator

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

Collaborator

benjamingr commented Dec 15, 2015

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

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Dec 15, 2015

Collaborator

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

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

Maybe it not the case when bluebird is loaded?

Contributor

lextiz commented Dec 15, 2015

Maybe it not the case when bluebird is loaded?

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Dec 15, 2015

Collaborator

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?

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

Yes. Will update when finished.

Contributor

lextiz commented Dec 15, 2015

Yes. Will update when finished.

@lextiz

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

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?

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

What is your Chrome version? I have 47.0.2526.80 m.

Contributor

lextiz commented Dec 15, 2015

What is your Chrome version? I have 47.0.2526.80 m.

@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Dec 15, 2015

Owner

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

Owner

petkaantonov commented Dec 15, 2015

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

@benjamingr

This comment has been minimized.

Show comment
Hide comment
@benjamingr

benjamingr Dec 15, 2015

Collaborator

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

Collaborator

benjamingr commented Dec 15, 2015

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

@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Dec 15, 2015

Owner

Can you link to line?

Owner

petkaantonov commented Dec 15, 2015

Can you link to line?

@lextiz

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 15, 2015

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Dec 15, 2015

Owner

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

Owner

petkaantonov commented Dec 15, 2015

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

@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Dec 15, 2015

Owner

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

Owner

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

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Dec 16, 2015

Owner

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/

Owner

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

This comment has been minimized.

Show comment
Hide comment
@lextiz

lextiz Dec 16, 2015

Contributor

Thanks!

Contributor

lextiz commented Dec 16, 2015

Thanks!

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