geckos.io icon indicating copy to clipboard operation
geckos.io copied to clipboard

Instantiating a geckos client within a web worker throws a ReferenceError

Open johnnyrainbow opened this issue 1 year ago • 2 comments

I am trying to init geckos client connection in a web worker, but it throws ReferenceError: RTCPeerConnection is not defined. Does not happen when running on the main thread. Is this a limitation of WebRTC or a Geckos bug?

I want to run my socket connections in a web worker, as my main thread is doing a lot of heavy lifting and I don't want it to impact data stream performance

johnnyrainbow avatar Jan 11 '24 07:01 johnnyrainbow

Had a similar idea but unfortunately: https://stackoverflow.com/a/54209625

According to the specifications [1, 2], navigator.mediaDevices and RTCPeerConnection are not defined for web workers, so WebRTC shouldn't be available on web workers for now.

reececomo avatar Jan 28 '24 04:01 reececomo

Maybe Transferable Streams could work?

reececomo avatar Jan 28 '24 04:01 reececomo