node-libs-browser
node-libs-browser copied to clipboard
process.nextTick polyfill is slow when tab is unfocused
trafficstars
The nextTick polyfill is supplied by https://github.com/defunctzombie/node-process/blob/master/browser.js which uses timers. See: https://github.com/defunctzombie/node-process/issues/86.
Because timers are often throttled when a tab is not active to improve battery life, they only run at 1Hz (once every second). This has a drastic performance impact in those scenarios.
It seems that the author won't change this for the time being, see: https://github.com/webtorrent/webtorrent/issues/1568#issuecomment-453682828
It would be cool to just map nextTick to setImmediate, as we are already providing that polyfill.