making sure its always done on the right thread. in case webrtc will be using webworkers later on.