Commit 8134487
committed
fix: avoid double RegisterObserver on DataChannel to prevent message loss
In M114, SctpDataChannel uses an ObserverAdapter that relays callbacks
through the signaling thread via SafeTask. When RegisterObserver was
called twice (first from DataChannelObserver's constructor, then from
RTCDataChannel's constructor), the adapter's SetDelegate call could
race with in-flight message delivery tasks on the signaling thread,
causing messages sent immediately after dc.onopen to be silently lost.
The fix removes the initial RegisterObserver from DataChannelObserver,
so registration only happens once in RTCDataChannel's constructor. The
SCTP layer queues any messages that arrive before an observer is
registered, and DeliverQueuedReceivedData() delivers them when
RegisterObserver is called.
Also dispatches the "open" state change event if the channel has
already transitioned to kOpen before the RTCDataChannel wrapper is
constructed, ensuring JS onopen handlers fire.1 parent 861d763 commit 8134487
1 file changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| |||
0 commit comments