Android: Crash randomly in ScriptingCore::executeFunctionWithOwner, samsung and huwei devices

Android: Crash randomly in ScriptingCore::executeFunctionWithOwner, samsung and huwei devices
0

Hi guys,
I’m new to cocos2d-js, I’m developing a turn-based game, and met some random crash on Android.

  • Cocos2dx: 3.14.1, Javascript
  • Target android 28, arm-v7a, arm-v8a
  • Most crashes occured on Samsung devices, some on Xiaomi, Huwei.

Here some stack traces I’ve got from Crashlytics, but it’s not enough to determine which exactly causes the crashes.

|0|libcocos2djs.so|(Missing)|
| --- | --- | --- |
|1|libcocos2djs.so|(Missing)|
|2|libcocos2djs.so|ScriptingCore.cpp line 1565

ScriptingCore::executeFunctionWithOwner(JS::Value, char const*, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) + 1565|
|3|libcocos2djs.so|ScriptingCore.cpp line 1498

ScriptingCore::handleTouchEvent(void*, cocos2d::EventTouch::EventCode, cocos2d::Touch*, cocos2d::Event*, JS::MutableHandle<JS::Value>) + 1498|
|4|libcocos2djs.so|ScriptingCore.cpp line 1478

ScriptingCore::handleTouchEvent(void*, cocos2d::EventTouch::EventCode, cocos2d::Touch*, cocos2d::Event*) + 1478|
|5|libcocos2djs.so|functional line 2439

std::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const + 2439|
|6|libcocos2djs.so|functional line 2439

std::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const + 2439|
|7|libcocos2djs.so|CCEventDispatcher.cpp line 1070

cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) + 1070|
|8|libcocos2djs.so|CCEventDispatcher.cpp line 912

cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) + 912|
|9|libcocos2djs.so|CCGLView.cpp line 447

cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) + 447|
|10|libcocos2djs.so|TouchesJni.cpp line 42

Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd + 42|


	libcocos2djs.so	
ScriptingCore.cpp line 1556
ScriptingCore::executeFunctionWithOwner(JS::Value, char const*, unsigned int, JS::Value*) + 1556
3	libcocos2djs.so	
cocos2d_specifics.cpp line 1289
JSScheduleWrapper::update(float) + 1289
4	libcocos2djs.so	
functional line 2439
std::function<void (float)>::operator()(float) const + 2439
5	libcocos2djs.so	
CCDirector.cpp line 277
cocos2d::Director::drawScene() + 277
6	libcocos2djs.so	
CCDirector.cpp line 1443
cocos2d::Director::mainLoop() + 1443

I guess that some objects is released in memory (perhaps by GC) but it’s still referenced somewhere in code. I also use cc.sys.isObjectValid() to check native objects before processing but it still crashes. The crash usually comes from JSScheduleWrapper::update. Is there anyway to avoid this ? Or validate object before calling executeFunctionWithOwner ?

Tks for your help.

Anyone ? Please.

This crash is really tough. Please help.

The crash log isn’t enough on its own, but from what is in it, the issue seems to be happening on a touch event. Is that correct? You could always add some logging output on each and every touch handler you’ve implemented, just to know which one gets called before the crash, and at least then you’ve narrowed in on the possible issue.

Aside from that, you’re still using Cocos2d-x 3.14.1, which is a 2 year old release, so much may have been fixed since then. Have you tried using Cocos2d-x 3.17.2 (or the latest code from github)?