Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just to explain core.async uses the fastest dispatching mechanism available, Firefox doesn't provide anything sensible like MessageChannel so we just resort to setTimeout. setTimeout in all major browsers has a 5ms delay between nested calls - thus all the discussion about setImmediate the past 2 years or so.

I am surprised about IE 10 since we do use setImmediate if available, but I haven't done much testing there - will need to look into it.



Can you use window.postMessage() on Firefox? Barnes & Noble's (?!) NobleJS library has a setImmediate() polyfill, which uses postMessage() on Firefox:

https://github.com/NobleJS/setImmediate/blob/master/setImmed...


We could use postMessage but it's rather frustrating since that's a global post and we have detect our own messages on the other side. So until Firefox supports MessageChannel we're unlikely to go that route.


Why can't you use postMessage? I use it for low-latency callbacks ala setImmediate and it works fine.


What do you use on Chrome?

What I see is that the page is using self-throttling to a ridiculous extent in Firefox, but not Chrome, with way too few letters changed between paints. Are you doing a single letter from each async callback or something?


Thanks for the explanation. On your machine what time does it take to color all the numbers on : IE10, Firefox and Chrome ?


FF probably takes about the same time - Chrome takes only a 5-6 seconds. I don't have IE 10 handy.


FF takes longer just because the script is pretty broken, imo: it only processes 4-5 chars per 16ms frame, and reflowing/painting each frame tick here is the expensive thing in all browsers. As a result, the behavior of the script in wall-clock time is O(N^2/K) where N is the number of chars and K is the number it processes in a single tick. Furthermore, its CPU consumption is pretty much constant no matter what K is for a wide range of K.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: