livekit/client-sdk-js

TrackProcessor: OverconstrainedError and TypeError Issues

robleroni opened this issue · 1 comments

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

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.