I am interested in to use webrtc with webworker. Is it possible?
I tried it but it did not work because it did not find the "window"
I am interested in to use webrtc with webworker. Is it possible?
I tried it but it did not work because it did not find the "window"
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.
For [1], navigator.mediaDevices
attribute is defined on Navigator
interface for window, but not on WorkerNavigator
interface for web worker.
For [2], RTCPeerConnection
interface is exposed to window ([Exposed=Window]
), but not to web worker ([Exposed=Worker]
).
The worker does not need to handle the webrtc connection it gets handeled outside the render process anyway and connected via MOJO:IPC internal so you can simply target from the render process a sharedArrayBuffer if your working in a secure context. Then you create a worker passing it the same arrayBuffer that u use to write out the WebRTC data.
Also wasm by design works in a worker on sharedMemory that means as soon as you do any processing in wasm your working in a worker.
It makes no sense to move WebRTC into a webworker as the final goal is to not copy data between the render process and what ever sends it via remote.
to eneable low latency copying data would destroy that.