Updated trouble shooting doc.

This commit is contained in:
genxium 2023-01-28 00:10:10 +08:00
parent 4097a8da75
commit 76cdbc8f1f
2 changed files with 35 additions and 16 deletions

View File

@ -135,3 +135,11 @@ __Windows__
``` ```
netstat -ano | grep <your_port> netstat -ano | grep <your_port>
``` ```
### 2.6 Checking native code crash on non-rooted Android phone
```
DeveloperOs> adb bugreport ./logs.zip
# The file "logs.zip" will be automatically pulled to current folder of the DeveloperOS, copy "logs/FS/data/tomestones" out of the zip, then use the binary "$NDK_ROOT/ndk-stack" to analyze whichever tombstone you're interested in, for example, I often use the following
DeveloperOs> ${NDK_ROOT}/ndk-stack.cmd -sym \path\to\DelayNoMore\frontend\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build\intermediates\ndkBuild\debug\obj\local\arm64-v8a\objs-debug -dump \path\to\tombstones\tombstone_03
# The param "-sym \path\to\objs" tells "ndk-stack" to decode "tombstone_03" with symbols provided by all the files inside that "\path\to\objs".
```

View File

@ -32,10 +32,12 @@ void _onRead(uv_udp_t* req, ssize_t nread, const uv_buf_t* buf, const struct soc
memset(gameThreadMsg, 0, gameThreadMsgSize); memset(gameThreadMsg, 0, gameThreadMsgSize);
memcpy(gameThreadMsg, buf->base, nread); memcpy(gameThreadMsg, buf->base, nread);
CCLOG("UDP read %d bytes from %s:%d, converted to %d bytes for the JS callback", nread, ip, port, strlen(gameThreadMsg));
free(buf->base); free(buf->base);
//uv_udp_recv_stop(req); //uv_udp_recv_stop(req);
if (6 != nread) {
// Non-holepunching
CCLOG("UDP received %d bytes from %s:%d, converted to %d bytes for the JS callback", nread, ip, port, strlen(gameThreadMsg));
cocos2d::Application::getInstance()->getScheduler()->performFunctionInCocosThread([=]() { cocos2d::Application::getInstance()->getScheduler()->performFunctionInCocosThread([=]() {
// [WARNING] Use of the "ScriptEngine" is only allowed in "GameThread a.k.a. CocosThread"! // [WARNING] Use of the "ScriptEngine" is only allowed in "GameThread a.k.a. CocosThread"!
se::Value onUdpMessageCb; se::Value onUdpMessageCb;
@ -52,6 +54,9 @@ void _onRead(uv_udp_t* req, ssize_t nread, const uv_buf_t* buf, const struct soc
} }
free(gameThreadMsg); free(gameThreadMsg);
}); });
} else {
CCLOG("UDP received hole punching from %s:%d", ip, port);
}
} }
static void _allocBuffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { static void _allocBuffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
@ -66,7 +71,9 @@ void _onUvStopSig(uv_async_t* handle) {
} }
void _onSend(uv_udp_send_t* req, int status) { void _onSend(uv_udp_send_t* req, int status) {
CCLOG("UDP send about to free req for status:%d...", status);
free(req); // No need to free "req->base", it'll be handled in each "_afterXxx" callback free(req); // No need to free "req->base", it'll be handled in each "_afterXxx" callback
CCLOG("UDP send freed req for status:%d...", status);
if (status) { if (status) {
CCLOGERROR("uv_udp_send_cb error: %s\n", uv_strerror(status)); CCLOGERROR("uv_udp_send_cb error: %s\n", uv_strerror(status));
} }
@ -92,8 +99,10 @@ void _punchServerOnUvThread(uv_work_t* wrapper) {
uv_udp_send(req, udpSocket, &sendBuffer, 1, (struct sockaddr const*)&destAddr, _onSend); uv_udp_send(req, udpSocket, &sendBuffer, 1, (struct sockaddr const*)&destAddr, _onSend);
} }
void _afterPunchServer(uv_work_t* wrapper, int status) { void _afterPunchServer(uv_work_t* wrapper, int status) {
CCLOG("UDP send about to free PunchServerWork for status:%d...", status);
PunchServerWork* work = (PunchServerWork*)wrapper->data; PunchServerWork* work = (PunchServerWork*)wrapper->data;
delete work; delete work;
CCLOG("UDP freed PunchServerWork for status:%d...", status);
} }
class PunchPeerWork { class PunchPeerWork {
@ -128,8 +137,10 @@ void _punchPeerOnUvThread(uv_work_t* wrapper) {
} }
} }
void _afterPunchPeer(uv_work_t* wrapper, int status) { void _afterPunchPeer(uv_work_t* wrapper, int status) {
CCLOG("UDP send about to free PunchPeerWork for status:%d...", status);
PunchPeerWork* work = (PunchPeerWork*)wrapper->data; PunchPeerWork* work = (PunchPeerWork*)wrapper->data;
delete work; delete work;
CCLOG("UDP send freed PunchPeerWork for status:%d...", status);
} }
class BroadcastInputFrameUpsyncWork { class BroadcastInputFrameUpsyncWork {