Trickle ICE
Title: Enable trickle ICE support across all strategies
Description
The current implementation disables trickle ICE. Before signaling, the code waits until the ICE gathering phase finishes and strips the a=ice-options:trickle attribute from the SDP, so the remote peer never expects additional candidates after the initial offer/answer.
Although thereβs a check for pc.canTrickleIceCandidates, no mechanism exists to send candidates incrementally via onicecandidate. Negotiation only runs once the full candidate list is available, which slows down connection setup compared to true trickle ICE.
Proposed Change
Remove SDP stripping of a=ice-options:trickle.
When supported, send local descriptions immediately.
Forward individual ICE candidates through a dedicated handler using pc.onicecandidate.
Accept ICE candidate objects in peer signaling.
Maintain secure encryption/dispatch/reception logic for candidate messages across all strategies (firebase, ipfs, mqtt, nostr, supabase, torrent).
Conditionally fall back to the current βvanillaβ approach if trickle ICE is unsupported.
Disabling trickle ICE was an intentional choice to minimize the number of trips to the peering relay. It was particularly relevant when the torrent strategy was the default since that one sends out offers in batches (unlike the others). I'm definitely in favor of adding ICE trickle if we:
- Make it configurable at the strategy layer - that is, not a user-facing config (I don't think that's necessary), but something torrent.js can specify in its config call to strategy.js (e.g.
trickle: false) - Make sure all the tests still pass consistently with trickle enabled (besides torrent) and that there are no ill side effects with sending out a higher rate of messages to the peering layer. For example, some Nostr relays start to rate limit quickly so in that case, being blocked/throttled by the relay outweighs any latency improvements from trickle ICE
- Ensure that a trickle default shows notable connection time improvements and no increase in connection errors (I assume this will be true barring relay issues, but worth making this a goal)
Thanks for digging into this!
Aligned on all counts! I'll include those objectives in the MR description.
I have a branch with a rough draft of the change. Are there pre-reqs to running the playwright tests? I'm on main and only about 1/2 are passing
10 failed
[chromium] βΊ test/tests.js:26:3 βΊ Trystero: ipfs βββββββββββββββββββββββββββββββββββββββββββββββ
[chromium] βΊ test/tests.js:26:3 βΊ Trystero: mqtt βββββββββββββββββββββββββββββββββββββββββββββββ
[chromium] βΊ test/tests.js:26:3 βΊ Trystero: supabase βββββββββββββββββββββββββββββββββββββββββββ
[firefox] βΊ test/tests.js:26:3 βΊ Trystero: ipfs ββββββββββββββββββββββββββββββββββββββββββββββββ
[firefox] βΊ test/tests.js:26:3 βΊ Trystero: mqtt ββββββββββββββββββββββββββββββββββββββββββββββββ
[firefox] βΊ test/tests.js:26:3 βΊ Trystero: supabase ββββββββββββββββββββββββββββββββββββββββββββ
[webkit] βΊ test/tests.js:26:3 βΊ Trystero: ipfs βββββββββββββββββββββββββββββββββββββββββββββββββ
[webkit] βΊ test/tests.js:26:3 βΊ Trystero: mqtt βββββββββββββββββββββββββββββββββββββββββββββββββ
[webkit] βΊ test/tests.js:26:3 βΊ Trystero: supabase βββββββββββββββββββββββββββββββββββββββββββββ
[webkit] βΊ test/tests.js:26:3 βΊ Trystero: torrent ββββββββββββββββββββββββββββββββββββββββββββββ
8 passed (1.3m)
@rogersanick some of the tests are flaky, but are most stable on Chromium right now.
Here's what I would do for testing right now:
- pull latest main snapshot
- comment out Firefox and Webkit on line 26 of playwright.conf.js
- comment out the runTests() line in supabase.spec.js (or any others you find failing too much). Supabase relies on a relay instance that is periodically shut down so usually fails.
Starting there should give you fairly reliable tests and a baseline to experiment with ICE experiments. Feel free to lower the timeout value in the Playwright config and remember to run npm run build after making a change before you rerun tests.
Thank you, and will do!