-
Notifications
You must be signed in to change notification settings - Fork 157
Reconnect errors #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Reconnect errors #845
Conversation
|
|
a68f1d4 to
11ee92a
Compare
| } | ||
|
|
||
| if signalingState == .haveLocalOffer, iceRestart, let sd = remoteDescription { | ||
| _reNegotiate = false // Clear flag to prevent double offer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this._pc && this._pc.signalingState === 'have-local-offer') {
const currentSD = this._pc.remoteDescription;
if (options?.iceRestart && currentSD) {
// 1. Rollback: Sets remote description
await this._pc.setRemoteDescription(currentSD);
// 2. DOES NOT set this.renegotiate = true
// 3. Falls through to create offer (line 291)
} else {
// 1. Defer: Sets renegotiate = true
this.renegotiate = true;
// 2. Returns immediately (skips offer creation)
return;
}
}vs Swift
if signalingState == .haveLocalOffer {
if !(iceRestart && remoteDescription != nil) {
// 1. Defer: Sets _reNegotiate = true
_reNegotiate = true
// 2. Returns immediately
return
}
// Else: ICE Restart path falls through...
}
// ... (offer ID increment) ...
if signalingState == .haveLocalOffer, iceRestart, let sd = remoteDescription {
// 1. Force clear _reNegotiate (Matches JS not setting it)
_reNegotiate = false
// 2. Rollback: Sets remote description
try await set(remoteDescription: sd)
// 3. Creates new offer immediately
return try await _negotiateSequence()
}| try await startReconnect(reason: .websocket) | ||
| } catch { | ||
| log("Failed calling startReconnect, error: \(error)", .error) | ||
| Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SerialRunnerActor (inside SignalClient._delegate)
│
├─> [Task 1] didUpdateConnectionState
│ └─> await startReconnect() ← blocking the actor
│ └─> waiting for offer...
│
└─> [Task 2] didReceiveOffer
└─> Can't enter because actor is busy with Task 1
|
@hiroshihorie this ain't trivial, I'd appreciate if you give it a spin in |
6384397 to
199d70b
Compare
| // force .full for next reconnect | ||
| _state.mutate { $0.nextReconnectMode = .full } | ||
| // Abort current connection attempt | ||
| await signalClient.cleanUp(withError: error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more or less equivalent to JS:
case LeaveRequest_Action.RECONNECT:
this.fullReconnectOnNext = true;
// reconnect immediately instead of waiting for next attempt
this.handleDisconnect(leaveReconnect);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (if-minor): maybe this is a good moment to adopt the .action of the leave request as well here? (backwards compatible of course in case it's unset/0).
We don't actually need a full reconnect on every leave request. But if it makes more sense as a follow up that also sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, moved to the action param here 👍
Re: backwards compatibility, I discarded the legacy canReconnect param, which mimics JS and no-op if unknown.
lukasIO
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me in general!
| // force .full for next reconnect | ||
| _state.mutate { $0.nextReconnectMode = .full } | ||
| // Abort current connection attempt | ||
| await signalClient.cleanUp(withError: error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (if-minor): maybe this is a good moment to adopt the .action of the leave request as well here? (backwards compatible of course in case it's unset/0).
We don't actually need a full reconnect on every leave request. But if it makes more sense as a follow up that also sounds good.
Resolves #844
offerId(symptoms)leaveActionparam vs legacycanReconnect