client-sdk-js icon indicating copy to clipboard operation
client-sdk-js copied to clipboard

Using codec unsupported by the server causes uncaught error in promise

Open bekriebel opened this issue 3 years ago • 6 comments

Using v0.12.1 from nmpjs

  1. Use a server that does not have h264 as an enabled codec
  2. Create a video track with videoCodec: "h264"
  3. Note that the track is not published to the server, but no error or warning is spawned
  4. Mute the video track
  5. Unmute the video track, the following error is thrown in the console log:
01:51:47.553 LocalTrack.js?0f51:77 restarting track with constraints {width: {…}, height: {…}, frameRate: {…}, deviceId: {…}, resolution: {…}}
01:51:47.568 LocalVideoTrack {_events: {…}, _eventsCount: 2, _maxListeners: undefined, attachedElements: Array(1), isMuted: false, …}
01:51:48.257 LocalTrack.js?0f51:92 re-acquired MediaStreamTrack
01:51:48.258 LocalVideoTrack.js?646b:6 Uncaught (in promise) Error
Promise.then (async)
step @ LocalVideoTrack.js?646b:7
eval @ LocalVideoTrack.js?646b:8
__awaiter @ LocalVideoTrack.js?646b:4
restartTrack @ LocalVideoTrack.js?646b:163
unmute @ LocalVideoTrack.js?646b:71
(anonymous) @ VM22733:1

bekriebel avatar Sep 11 '21 08:09 bekriebel

hey @bekriebel, I'm unable to reproduce this error. Which browser / OS did you see this with?

Can you reproduce it with the sample JS client? If so, please attach a code snippet on what you've changed.

davidzhao avatar Sep 13 '21 06:09 davidzhao

@davidzhao Yeah, I'm able to reproduce with the client as well. Tested with both Chrome and Edge on Windows 11 (I'll try again with Windows 10 a bit later, but I doubt that's an issue considering that the video works and it's just unmute that is failing).

The only change needed to the JS client sample is to add videoCodec: 'h264', to the room connect call:https://github.com/livekit/client-sdk-js/blob/ee44df22ddc4f1dd1227d3619b332b8095226d99/example/sample.ts#L177-L185 and then connect, mute the video track, and unmute the video track.

This is connecting to a server that is v0.12.5 with my prefer local node selection change added.

bekriebel avatar Sep 14 '21 20:09 bekriebel

Ahh, I figured it out. I didn't realize that h264 was disabled server-side by default. after adding

room:
  enabled_codecs:
    - mime: audio/opus
    - mime: video/vp8
    - mime: video/h264

to my livekit-config it is no longer throwing the error. Ideally this would output a warning or error message and fall back to VP8 when h264 isn't available.

bekriebel avatar Sep 14 '21 23:09 bekriebel

ah yes.. that would do it. we removed h264 from the default due to a limitation with supporting tracks using multiple codecs in the same room. Once that bug is fixed, we should be able to add both into enabled_codecs by default.

for now, just a heads up that mixing different video codecs in the same room is likely to lead to bugs where participants wouldn't be able to receive certain tracks that's different from their initial subscription.

davidzhao avatar Sep 15 '21 05:09 davidzhao

Thanks. Yeah, I noticed that mixing the codecs wasn't working very well. I was also getting a lot of frame drops with h264, so I've just disabled it again for now. I updated the issue to reflect what is actually happening. Feel free to close if you consider it a non-issue, though.

bekriebel avatar Sep 15 '21 06:09 bekriebel

oh interesting.. I think we should keep it open for now. I was able to reproduce it with the same setup.

davidzhao avatar Sep 15 '21 06:09 davidzhao