I have been trying to implement WebRTC "perfect negotiation" as explained in this blog post. Unfortunately, I'm very often triggering errors on the polite side of the conversation (in the following linked code, this is the last peer to join).
The two most frequent errors are InvalidStateError: Cannot rollback local description in stable
caused by this line and ONN DOMException: "Cannot set local offer in state have-remote-offer"
triggered here and caused by this line. That second error is quite inexplicable to me since the line before checks that we should be in stable
state and it is the first async call following that.
If you want to try it for yourself, my code is hosted on GitHub. It can be deployed directly on Heroku:
heroku create
git push heroku master
or can be tested locally with a self-signed certificate by changing lines 1, 7-10 and 15 of server.js.
I have had those issues when testing with desktop Firefox at versions 76, 73, desktop Chromium 80 and their up-to-date mobile versions on Android. Any help on this would be very much appreciated. And I'd love to also have this reliably working on iPads (Safari >= 11) which I can't personally test.