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

On some of my machines I got the error "Error creating offer: SyntaxError: Failed to construct 'RTCPeerConnection': '' is not a valid URL." #1647

Closed qiulang closed 6 months ago

qiulang commented 6 months ago

Please read first!

Please use discuss-webrtc for general technical discussions and questions. If you have found an issue/bug with the native libwebrtc SDK or a browser's behaviour around WebRTC please create an issue in the relevant bug tracker. You can find more information on how to submit a bug and do so in the right place here

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed.

Browser affected

  System:
    OS: macOS 14.1.2
    CPU: (8) arm64 Apple M2
    Memory: 82.39 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 120.0.6099.109
    Safari: 17.1.2

Description

On some of my machines, when trying https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

I get "Error creating offer: SyntaxError: Failed to construct 'RTCPeerConnection': '' is not a valid URL."

Failed to construct 'RTCPeerConnection

The console log shows ,

Creating new PeerConnection with config={"iceServers":[{"urls":["stun:stun.l.google.com:19302"]},{"urls":[""],"username":"","credential":""},{"urls":[""],"username":"","credential":""},{"urls":[""],"username":"","credential":""}],"iceTransportPolicy":"all"}

Steps to reproduce

I have restart the machines and Chrome, but I still get the error. But other browsers do not have it.

alvestrand commented 6 months ago

"" is not a legal URL, so the error message is quite correct.

I can reproduce the error by pressing "Add Server" a few times before hitting "Gather candidates" without filling in anything in the URI field of the form. Is this what's happening?

It might be good if the UI did not allow adding an empty URI.

qiulang commented 6 months ago

But I didn't know how I triggered the problem and it just happened and only happened in some of my machine.

alvestrand commented 6 months ago

Try it again and be careful to NOT touch the "Add Server" button, and see if you can reproduce.

qiulang commented 6 months ago

On one of my machine it always happens now but it used to work so I had thought it may be because of some Chrome extensions I installed. I closed all these extension but it still happens. On my other machine I still can not trigger it.

fippo commented 6 months ago

The "Reset to defaults" button should clear the invisible elements. But we should not be adding them in the first place...

qiulang commented 6 months ago

@fippo yes "Reset to defaults" does fix my problem. I just can't find out why it happened in the first place.

qiulang commented 6 months ago

Hi I am closing this issue as I don't want to "waste" my time on this minor issue.

alvestrand commented 6 months ago

See if PR #1648 fixes your issue.