webrtc / samples

WebRTC Web demos and samples
https://webrtc.github.io/samples
BSD 3-Clause "New" or "Revised" License
13.74k stars 5.69k forks source link

Fix error message handling in getusermedia/gum. #1664

Closed bc-lee closed 1 month ago

bc-lee commented 1 month ago

Description

Currently, when some errors occur in the getusermedia/gum demo, the error message isn't handled correctly because the constraints object might not have required properties in some cases. This patch fixes the error message handling by using the error object directly and dumping it as a JSON string.

Purpose

fippo commented 1 month ago

I assume this only happens if one manually sets the video constraints to cause an overconstrained error.

Can you revert to using errorMsg and (for consistency) prefix with the error name in addition to the somewhat helpful error message?

bc-lee commented 1 month ago

I assume this only happens if one manually sets the video constraints to cause an overconstrained error.

I encountered this issue without modifying the constraints. I was testing Linux WebKitGTK to see if media capture streams (and WebRTC) were working. Its implementation seems to be buggy, as I got an OverconstrainedError when trying to get the video stream, even though I didn't set any constraints.

fippo commented 1 month ago

Thank you! Maybe @philn knows more about what WebKitGTK might be doing in wrong ways, it did show this code was wrong which is 👍

philn commented 1 month ago

That demo works just fine in my development build.