Repository navigation
Commit 5e490e3
authored
Send the offer requested while an answer is being applied (#1284)
## Problem
A track published right after another one can stay unpublished, with no
error. The common case is `setCameraEnabled(true)` followed by
`setMicrophoneEnabled(true)` after connecting: the camera is published,
the microphone never reaches the server, and remote participants never
see it.
## Cause
A publisher offer requested while the previous offer is still pending is
deferred. `createAndSendOffer` sets `renegotiate`, and
`setRemoteDescription` sends the deferred offer once the answer is
applied.
`createAndSendOffer` read the signaling state, then awaited
`getRemoteDescription()`, and only then set the flag. When the answer
finished applying inside that gap, `setRemoteDescription` had already
checked the flag. The flag was then set with nobody left to act on it,
so the offer was never sent.
The window was always there, but it was one platform call wide. The
duplicate answer guard from #1257 reads the signaling state before it
applies an answer, which gives a request that arrives just after the
answer the time to see the old state. Starting audio capture can delay
the camera offer by more than a second on macOS, which lines the
microphone request up with the camera answer. #1257 is not in a
published release.
Trace from an instrumented build:
```
41.639120 answer arrived reads the signaling state first
41.639429 createAndSendOffer enter the microphone request
41.641056 createAndSendOffer saw have-local-offer then awaits getRemoteDescription
41.642264 after setRemoteDescription(answer) renegotiate=false, checked once
41.642659 renegotiate flag set too late
```
The server log of the same run shows an answer with one video section
and no audio section, and no later offer from the publisher.
## Fix
Set the flag right after the state is read, with nothing awaited in
between. The remote description is now read only for an ICE restart, the
only path that uses it.
## Testing
- New unit test in `test/core/transport_negotiate_test.dart`. It fails
on `main` (one offer instead of two) and passes here.
- e2e-flutter `NodeFailureTest` on macOS, which publishes camera then
microphone: 6 failures in 11 runs before, 11 passes in 11 runs after.
With the fix the same interleaving still occurs, the answer handler now
sees the flag and sends the deferred offer.
- e2e-flutter full suite on macOS with the fix: 43 pass, 0 fail, 3
expected failures, 8 skips.
## Notes
- #1262 (offer ids) keeps the same await between the state read and the
flag, so it still needs this. The two merge cleanly, one test line needs
adapting to the new `onOffer` signature.
- This should be part of 2.14.0.1 parent f38055a commit 5e490e3
3 files changed
Lines changed: 45 additions & 3 deletions
File tree
- .changes
- lib/src/core
- test/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
382 | 389 | | |
383 | | - | |
| 390 | + | |
384 | 391 | | |
385 | 392 | | |
386 | | - | |
387 | | - | |
388 | 393 | | |
389 | 394 | | |
390 | 395 | | |
| 396 | + | |
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
54 | 89 | | |
55 | 90 | | |
56 | 91 | | |
| |||
0 commit comments