I had impression, that if I required something in renderer with
remote.require, then everything I invoke on those objects will be processed in main process. But looks like it’s not what I thought it is.
Here is an example:
# Renderer process fib = remote.require './test' $('#fib-start').click -> fib (result) -> console.log(result) # test.coffee f = (n) -> if n is 0 0 else if n is 1 1 else f(n-1) + f(n-2) module.exports = (callback) -> setTimeout(-> res = f(45) callback(res) , 0)
My expectation was that renderer process won’t be affected with computation involved. But when I run this my whole window freezes for 15 seconds while it computes.
The main question in the title is of my post is invalid in a first place. I don’t need (and shouldn’t) to do CPU intensive operations in main process at all - because this is the place where all window and OS management is happening and by loading it up I will hang window itself.
The right way to do this is the same as for any other node app - to use child_process.spawn or fork.