AgoraIO-Community / AgoraWebSDK-NG

The Next Generation of Agora Web SDK
https://agoraio-community.github.io/AgoraWebSDK-NG/
162 stars 75 forks source link

Stuttering audio in iOS14.2 only NG version #108

Open yokurin opened 3 years ago

yokurin commented 3 years ago

Describe the bug

I only use voice call. I created 1to1 voice call system in web page with the sdk agora-rtc-sdk-ng (v4.1.1). This based on a code in a tutorial page of it.

If the caller or callee is iOS 14.2, the audio is interrupted and cannot be heard well. In order to isolate the problem, I tested it with 3.x and 4.x in iOS14.2 This audio bug occurred only in 4.x.

I used a simple demo. 3.x demo:https://webdemo.agora.io/agora-web-showcase/examples/Agora-Web-Tutorial-1to1-Web/ 4.x demo:https://agoraio-community.github.io/AgoraWebSDK-NG/demo/basicVideoCall/index.html

SDK Logs

Platform and Browser: iOS14.2 Safari

SDK Version: 4.1.1

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://agoraio-community.github.io/AgoraWebSDK-NG/demo/basicVideoCall/index.html in iOS14.2.
  2. Call
HAHAHA44 commented 3 years ago

It maybe a bug of WebAudio and WebRTC API using together in the latest iOS Safari. We are trying to find out the reason.

porterde commented 3 years ago

I have what I think is the same issue but I had a very simple way to demonstrate it.

<!DOCTYPE html>
<html lang="en">
<body>
  <audio id="audio-test">
    <source src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3" />
  </audio>
  <button onclick="navigator.mediaDevices.getUserMedia({ audio: true });">Capture microphone</button>
  <button onclick="document.getElementById('audio-test').play();">Play sound</button>
  <button onClick="import('https://download.agora.io/sdk/web/AgoraRTC_N.js')">Load Agora NG SDK</button>
  <button onClick="import('https://cdn.agora.io/sdk/release/AgoraRTCSDK-3.2.3.js')">Load Agora 3 SDK</button>
</body>
</html>

1, Load that page in Safari on iOS 14.2.

  1. Click "Capture microphone" button then Allow
  2. Click "Play sound" button. Sound plays fine.
  3. Click "Load Agora NG SDK" button. Sound begins stuttering.

With Agora NG SDK loaded the sound plays fine unless the microphone is also captured. Apparently something Agora SDK does on load together with microphone capture breaks sound playback.

Clicking "Load Agora 3 SDK" button momentarily pauses the sound, but then it resumes fine.

This appears to confirm something different that NG SDK does on initialisation compared to v3 that is breaking audio playback.

(btw if you play the sound first, then capture the microphone, the sound quality changes. I believe this is related to https://bugs.webkit.org/show_bug.cgi?id=211959)

aandrewww commented 3 years ago

I have the same issue. Fix it, please!

aandrewww commented 3 years ago
Screenshot 2020-12-28 at 21 27 13

It's log from safari. multiple logs about "rebuild web audio" - every 4 seconds. And then I tried to play a track... and multiple resume success logs in onetime

aandrewww commented 3 years ago

It's a very interesting part of code. But it could be a root of the problem.

Recursive call via autoclick (it's part of code from AgoraWebSDK_N-v4.2.1-0-gf505b57):

Screenshot 2020-12-28 at 22 21 15 Screenshot 2020-12-28 at 22 24 05