I have a turn based multiplayer game. So when i see an inactive user i kick him of the server (close the websocket connection from the server). For some reason this causes a crash on ios (i have NOT tested other devices) about 80-90% of the time.
I am sorry if the issue has been reported allredy.
So the way i do this i have a ccbi scene that opens a WS connection to the server /login and after they login and start the game i close that WS connection on client and start a new scene that opens a connection to /game. THEN when i close my websocket connection on the server i get that crash.
So i saw that void WebSocket::onSubThreadEnded() is empty anyway so just comment the crashing line out. Seems to fix it
void WsThreadHelper::quitSubThread()
{
_needQuit = true; // this may be called when connection is close, and then _ws must be deleted.
// set _needQuit true is not safe enough to ensure _ws lives after wsThreadEntryFunc exiting...
// may be we should block here until wsThreadEntryFunc thread end
}
void* WsThreadHelper::wsThreadEntryFunc(void* arg)
{
_ws->onSubThreadStarted();
while (!_needQuit)
{
if (_ws->onSubThreadLoop())
{
break;
}
}
_ws->onSubThreadEnded(); // this code run after quitSubThread(), and most of the time _ws is deleted
return (void*)0;
}
By the way,onSubThreadEnded is a virtual function, commenting the line is a bad solutionā¦
Will this issue be fixed in next release?