-
Notifications
You must be signed in to change notification settings - Fork 110
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
Core disconnect crash #385
Comments
@joeljfischer is this existent on iAP2, or only TCP/IP? |
I think it's only TCP/IP, but I'm not sure. |
To solve this issue, we can actually check the } else if (kCFSocketDataCallBack == type) {
SDLTCPTransport *transport = (__bridge SDLTCPTransport *)info;
if (CFDataGetLength((CFDataRef)data) > 0) {
NSMutableString *byteStr = [NSMutableString stringWithCapacity:((int)CFDataGetLength((CFDataRef)data) * 2)];
for (int i = 0; i < (int)CFDataGetLength((CFDataRef)data); i++) {
[byteStr appendFormat:@"%02X", ((Byte *)(UInt8 *)CFDataGetBytePtr((CFDataRef)data))[i]];
}
[SDLDebugTool logInfo:[NSString stringWithFormat:@"Read %d bytes: %@", (int)CFDataGetLength((CFDataRef)data), byteStr] withType:SDLDebugType_Transport_TCP toOutput:SDLDebugOutput_DeviceConsole];
[transport.delegate onDataReceived:[NSData dataWithBytes:(UInt8 *)CFDataGetBytePtr((CFDataRef)data) length:(int)CFDataGetLength((CFDataRef)data)]];
} else {
[SDLDebugTool logInfo:@"Could not connect to Core. Disconnecting…" withType:SDLDebugType_Protocol toOutput:SDLDebugOutput_File | SDLDebugOutput_DeviceConsole];
[transport.delegate onTransportDisconnected];
}
} else { The only issue we run in to, however, is that it doesn't seem there is a way for us to properly dispose of the proxy and transport. If we issue this delegate function call, based on the logs it appears that the transport gets re-initialized, followed by the proxy.
We should try to see if there is a way for us to properly dispose of the transports and proxy. |
It appears that there currently is not a way to do this well. We may have to wait for v5.0.0 to rearchitecture portions of the proxy to handle dealloc'ing in the proper order. |
@asm09fsu I think this fix is valid. It seems like the reason why you see SDLTCPTransport Init after calling OnProxyDisconnect is that the Example App implements OnProxyClosed as - (void)onProxyClosed {
[self resetProxyWithTransportType:self.currentTransportType];
} If you agree I'll issue a hot fix - I am getting annoyed by this problem every day. |
@justinjdickow That's the correct code for |
Nothing, it's fine the way it is. It's the exact same behavior as trying to start the proxy the way you are in |
The issue just comes back to the fact that we don't handle the fact that we'lol get a data call back when the connection is severed from the host. If we look here we get some explanation |
Right, which I why I said your solution is valid, checking the data length is another indication that the connected was severed by the host. Since we don't handle it, it manages to propagate itself up to trying to determine the packet type and crashes in an exception we throw (for some reason). Instead, if we call |
The problem Alex saw is that there's a race condition preventing the automatic reconnection attempt. There would be a failure, then never an attempt to reconnect without killing and restarting the app. |
I tested the fix myself on a branch, and I think it's fine to pull in for now. It's definitely not okay for production, that would need a full retry strategy, but for debug, it's useful. |
Bug Report
If Core is disconnected while an app is connected, that app will crash.
Reproduction Steps
Expected Behavior
The app to close its connection gracefully
Observed Behavior
The app crashes
OS & Version Information
The text was updated successfully, but these errors were encountered: