Hi, Is there a way we can run a pre-check before a...
# sdk-web
m
Hi, Is there a way we can run a pre-check before allowing users to join the call — to ensure their network, audio, and other key settings are in good shape and won’t cause issues during the call? Some of our users have reported issues like one person not being able to hear the other. In some cases, they refresh the page and the call works fine afterward.
h
it is common UX to have a pre-join screen to test those things. There is this PreJoin component that is used on livekit meet demo You can start by using the component or building your own following the same strategy, and then you can add more checks over time
currently the PreJoin is good to check video and audio, but you might add other checks for network, browser compatibility and any other thing that you might need
Also, this month on the app that I work on, we are getting more issues exactly like yours, and we are currently working to identify and fix them. Do you have more info on what browser+OS your users with issues are using?
m
Most of our users are on Chrome or Microsoft Edge, and the OS is primarily Windows (around 99%) and macOS. In our business logic, the call is not displayed like a meeting — we simply display a custom badge indicating that the user is in a call. So integrating a traditional pre-join screen might be a bit tricky in our setup. That said, is there a way to access LiveKit’s pre-join checks programmatically? We’ve already built a few custom pre-test steps — including audio input/output tests and a network test using the Cloudflare API — but despite that, we’re still seeing issues like one participant not being able to hear the other.
l
You can use our ConnectionChecker in the JS SDK- here are some more details on it
🙌 2
👍 1
h
@melodic-kangaroo-88838, in our case we had different issues on different devices. On mobile we are narrowing it down to overheat and some race conditions with user media being re-requested and not released, but on desktop our main audio issues were: • Audio very quiet / soft • Audio echoing when users are using speakers So, not exactly "no audio" coming through. The "one participant not being able to hear the other" is 100% no audio, or maybe the volume being too low, or the audio being distorted?
✅ 1
m
Thanks @loud-dawn-97520 for sharing the ConnectionChecker. I'll check.
h
and thanks Hamdan! I didn't know the connection checker and it will be useful for us as a next step. We identified that
currentAudioTrack.checkForSilence();
will also be useful for us to capture more data and maybe identify users that might be connected correctly, but with the wrong mic device
✅ 1
m
@high-flower-44013 Got it! yeah gotcha! we also prevented mobile users and made our platform desktop only because of the same concern. For the Audio we're passing this flags and its helping us with the quality though.
Copy code
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true,
there is one more
voiceIsolation: true
but we're not using it, maybe you can give it a try.
Copy code
So, not exactly "no audio" coming through. The "one participant not being able to hear the other" is 100% no audio, or maybe the volume being too low, or the audio being distorted?"
yeah could be, but user are leaving the call by mentioning that they are not able to listen to other, or sometime they are able to listen but after few minutes they stopped listening.
currentAudioTrack.checkForSilence();
interesting.. Thanks for sharing, I'll check...
h
thanks for sharing! we just adjusted our settings to:
Copy code
echoCancellation: true, // even though Krisp SDK mentions to disable it for better results, the echo was a huge issue
autoGainControl: true, // without it, some devices (more frequently chrome) had the mic muffled on first media acquisition, but would not have this issue after switching devices
noiseSupression: trueIfKrispIsNotAllowedForThisDevice,
voiceIsolation: false, // we decided to always use this as false to have less variance
And we enable krisp on desktops that are not low power.
✅ 1
m
Gotcha!
h
Also, the
participant.isSpeaking
might be interesting to look at, even if your app does not have a speaking indicator, because when a remote participant speaks, their browser will detect if they are speaking and send an event. So, if the local user receives this event from a remote participant, but no audio is played, we can know that the remote user mic is working but something went wrong on the publication, SFU, subscription or playback.
✅ 1
m
gotcha!!
I see
sure will try them out.
@high-flower-44013 Btw here's our
LiveKit
configuration. is this correct, or anything we can modify to make it more robust ?
Copy code
<LiveKitRoom
      serverUrl={serverUrl}
      token={token}
      connect={true}
      data-lk-theme="default"
      style={{ height: '100%', background: 'transparent', width: '100%', zIndex: 1000 }}
      audio={false}
      video={false}
      connectOptions={connectOptions}
      options={{
        audioCaptureDefaults: {
          echoCancellation: true,
          noiseSuppression: true,
          autoGainControl: true,
          sampleRate: 48000,
          channelCount: 1,
          deviceId: deviceId,
          // latency: 0.1,
        },
        disconnectOnPageLeave: !isUserLocked,
        adaptiveStream: true,
        dynacast: true,
      }}
      onConnected={() => {
        setIsConnecting(false);
        console.log(':white_check_mark: LiveKit connected successfully');
        onConnected?.();
      }}
      onDisconnected={handleDisconnected}
      onError={handleError}
      onMediaDeviceFailure={handleMediaDeviceFailure}
      onEncryptionError={handleEncryptionError}
    >
 
      <CallInterface
        pairedWith={pairedWith}
        onCallEnd={onCallEnd}
        onPartnerConnected={onPartnerConnected}
        onConnectionQualityChange={onConnectionQualityChange}
      />
      <RoomAudioRenderer />
</LiveKitRoom>
h
this seems right, based on what I know. dynacast could be an issue if there is some bug, since it will pause the publication and only enable it when there is a subscriber (at least on video. Never checked it on audio). But not likely. Also I see a
onEncryptionError
. If you are using encryption, is there any chance that it fails on some devices? Just a random hypothesis, though.
Also, if you can find the problematic session / room on livekit dashboard, it is valuable to look at the participants events, published tracks (bitrate, encoding, etc), and the publish / subscribe events.
m
I see your point, will try without
dynaCast
however adaptiveStream is good though right?
we're checking livekit cloud logs constantly, we're noticing one pattern, those calls which face issues, has more bandwidth / network drop at the end..
wondering what we can do here ?
h
I think adaptiveStream only applies to video (checks for video size on-screen to change what video quality is transmitted). Not 100% sure
the bandwidth drop is a good lead! I would look at the participants pages separatedly and try to see if it is a drop when sending or when receiving. It helps isolating where the issue could be. Also, looking closely if there was a unsubscribe at any point, or if the publisher stopped publishing. This helps to narrow down your search to one or the other end
m
yeahh!!!
thanks for the insights!! we've been doing it for past few days!
Common ground came is network issue 1. wondering what we can do about it. 2. I saw some of the failed calls had packet loss issue, and it led to audio missing issue for one of the user
h
we have managed to improve some issues on our app. Turns out we were using vp8 for everyone to be safe, but some mobile devices were overheating and being CPU constrained, and performance was not good on desktop as well. So on our case the intense CPU usage was causing some of the audio and video random dropouts. We ended up publishing h.264 for iOS devices and vp9 for the rest and the performance is much better. This performance improvement seems to have solved a large part of current audio/video issues. Might be good to check if performance is an issue for you as well.
m
interesting....
change the codec for audio as well?
h
No, we didn't change the codec for audio. But the overall app CPU usage was causing the media stream to get bad. I don't know if it is your issue but might be good to consider it
m
gotcha!!
are you using self hosted livekit ?
h
we use the cloud service
m
gotcha!
c
Hi @high-flower-44013 why did you decide on h.264 for iOS? Is it because of Safari < 15 or was there as other reason as well? was there any other things you find out in the meantime? thank you for your answer. I know this is an old thread, but it would be super helpful
h
Hi! we are using h.264 for iOS because on our experiments we identified that other codecs were using software encoder on iOS, and h.264 was using hardware encoding. It solved a lot of issues related to phones overheating and things starting to fail due to CPU constraints
in theory iOS supports hardware encoding for some other codecs, but even when available safari was using software encoding. We didn't investigate if we would be able to enforce hardware encoding (specially through livekit's API) with other codecs, but might be worth investigating if you have constraints on using h.264
👍 1