cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.22k stars 7.05k forks source link

IOS web socket crash when close app #18972

Open zzyAZU opened 6 years ago

zzyAZU commented 6 years ago

Steps to Reproduce:

--------------------------------------- bug 1 std::__1::system_error mutex lock failed: Invalid argument

0 libc++abi.dylib 0x00000001828f6000 + 107852
1 libc++abi.dylib std::terminate() + 60
2 Badam Oyuni LuaWebSocket::~LuaWebSocket() + 12
3 Badam Oyuni tolua_collect_WebSocket(lua_State*) + 36
4 Badam Oyuni _lj_BC_JFUNCV + 44
5 Badam Oyuni _class_gc_event + 224
6 Badam Oyuni _lj_BC_JFUNCV + 44
7 Badam Oyuni _gc_finalize + 412
8 Badam Oyuni _lj_gc_finalize_udata + 28
9 Badam Oyuni _cpfinalize + 28
10 Badam Oyuni _lj_vm_cpcall + 100
11 Badam Oyuni _lua_close + 124
12 Badam Oyuni cocos2d::LuaStack::~LuaStack() + 44
13 Badam Oyuni cocos2d::LuaStack::~LuaStack() + 12
14 Badam Oyuni cocos2d::LuaEngine::~LuaEngine() + 44
15 Badam Oyuni cocos2d::LuaEngine::~LuaEngine() + 12
16 Badam Oyuni cocos2d::ScriptEngineManager::destroyInstance() + 44
17 Badam Oyuni cocos2d::ApplicationProtocol::~ApplicationProtocol() + 36
18 libsystem_c.dylib __cxa_finalize_ranges + 384
19 libsystem_c.dylib exit + 24
20 UIKit -[UIApplication applicationWillTerminate]
21 UIKit _98-[UICanvasLifecycleMonitor_Compatability deactivateEventsOnly:withContext:forceExit:completion:]_block_invoke.271 + 344
22 UIKit __runAfterCACommitDeferredBlocks + 292
23 UIKit __cleanUpAfterCAFlushAndRunDeferredBlocks + 288
24 UIKit __afterCACommitHandler + 132
25 CoreFoundation _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
26 CoreFoundation ___CFRunLoopDoObservers + 412
27 CoreFoundation ___CFRunLoopRun + 1292
28 CoreFoundation CFRunLoopRunSpecific + 436
29 GraphicsServices GSEventRunModal + 100
30 UIKit UIApplicationMain + 208
31 Badam Oyuni main (main.m:13)
32 libdyld.dylib _start + 4

以上是bugly 的崩溃报错 Android 无问题 ios 崩溃率10%左右挺高的 大概看了下实现的代码,感觉部分处理data race的逻辑处理的不到位,更详细也就没看了 我这边将websocket 改成单线程后就没崩了, 对于我们项目单线程够用了 而且还省电,也解决了崩溃问题。

ps. 我们项目是棋牌项目,每个小游戏都是一个 socket 所以有频繁创建销毁websocket的情况

zzyAZU commented 6 years ago

这个报错貌似影响不大主要是关闭游戏的时候触发的

midgithub commented 6 years ago

@CarlZhongZ 你好 我也在使用websocket 有一些问题想交流一下 方便的话可以留个QQ不。