livekit / client-sdk-js

LiveKit browser client SDK (javascript)
https://livekit.io
Apache License 2.0
334 stars 143 forks source link

TrackProcessor: OverconstrainedError and TypeError Issues #1148

Closed robleroni closed 3 months ago

robleroni commented 3 months ago

Describe the bug

After #1081, using the original track as the processed track in a track processor is no longer possible.

It results in an OverconstrainedError: The track is not connected to any source error because the track is being stopped before trying to set the constraints again:

const dummyProcessor: TrackProcessor<Track.Kind> = {
    name: 'Dummy',
    init: async ({ track }) => { dummyProcessor.processedTrack = track },
    restart: async () => {},
    destroy: async () => {},
}
await track.setProcessor(dummyProcessor);

I tried to clone the track as well:

const dummyProcessor: TrackProcessor<Track.Kind> = {
    name: 'Dummy',
    init: async ({ track }) => { dummyProcessor.processedTrack = track.clone() },
    restart: async () => {},
    destroy: async () => {},
}
await track.setProcessor(dummyProcessor);

But this results in the following error, because stopProcessor removes the processorElement after initialization.

TypeError: Cannot read properties of undefined (reading 'srcObject')
    at attachToElement (Track.ts:344:5)
    at LocalTrack.ts:489:7
    at Generator.next (<anonymous>)
    at fulfilled (logger.ts:91:1)

Reproduction

Add the above track processor.

Logs

No response

System Info

Brwoser: Chrome(125.0.6422.112)
livekit-client: 2.1.5

Severity

blocking an upgrade

Additional Information

No response

lukasIO commented 3 months ago

But this results in the following error, because stopProcessor removes the processorElement after initialization.

good timing, I just opened #1149 to address a related issue.