Too many enumerateDevices requests
This unusually high number of device enumeration requests indicate a bug in the application's logic or inefficient device handling.
Description
The navigator.mediaDevices.enumerateDevices() API returns a list of available media input and output devices. Unlike getUserMedia, it does not require user permission to list devices (though labels may be empty until permission is granted).
Calling this API repeatedly is unnecessary in most cases. The device list typically only changes when the user connects or disconnects hardware, or when they grant or revoke permissions. Polling or calling it on every render can indicate a bug in the application's logic or inefficient device handling.
What do we do here?
We count the number of enumerateDevices API called per minute and we mark an observation when there is at least 6 calls per minute.
Recommendations
- Cache the result of
enumerateDevices()and only re-call when thedevicechangeevent fires - Avoid calling enumerateDevices in frequently re-rendering components or tight loops
- Consider debouncing or throttling if you need to react to device changes