Objective
This article explains how to test getUserMedia latency in your browser’s Developer Console. This can help troubleshoot issues with Flex Voice, Voice JS SDK, or Video JS SDK by measuring how quickly your browser can access the microphone. Running this test may reveal device, browser, or system-related issues affecting Twilio voice or video products.
Product
Twilio Flex
Environment
legacy Twilio Console
User Account Permission/Role(s) Required
No special permissions are required. You need access to a browser with Developer Console capabilities.
Procedure
- Open your browser’s Developer Console (usually by pressing F12 or Ctrl+Shift+I).
- Copy and paste the following script into the Twilio Console and press Enter:
Script
(async () => {
console.log("Requesting getUserMedia...");
const start = performance.now();
try {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const end = performance.now();
console.log("getUserMedia resolved.");
console.log(`:stopwatch: Latency: ${(end - start).toFixed(2)} ms`);
// Clean up the stream
stream.getTracks().forEach(track => track.stop());
} catch (err) {
console.error("getUserMedia failed:", err);
}
})();
Additional Information
- This test requests microphone access. Your browser will prompt you for permission.
- Latency may vary depending on your device, browser, and system load.
- The script stops all tracks after measuring latency to clean up resources.
- For more troubleshooting tips, see related articles in the Twilio Help Center.