jonseg
1
Hi,
I have this error randomly:
Fatal signal 11 (SIGSEGV) at 0x59f82000 (code=1), thread 30894 (Thread-2921)
I use this command for more info:
adb logcat | /path_to/android-ndk-r9d/ndk-stack -sym obj/local/armeabi
And I have this error:
********** Crash dump: **********
Build fingerprint: ‘motorola/tervigon/wingray:4.1.2/JZO54K/485486:user/release-keys’
pid: 30875, tid: 30894, name: Thread-2921 >>> com.project.project <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 59f82000
Stack frame #00 pc 0000e218 /system/lib/libc.so (memcpy+172): Routine ??
??:0
Stack frame #01 pc 0002a5a4 /system/lib/egl/libGLESv2_tegra.so
Stack frame #02 pc 0001551c /system/lib/egl/libGLESv2_tegra.so (glBufferData+416)
Stack frame #03 pc 0049d0b4 /data/data/com.project.project/lib/libcocos2dcpp.so (cocos2d::DrawNode::init()+1036): Routine cocos2d::DrawNode::init() at /path_to/Project/proj.android/jni/…/…/cocos2d/cocos/./2d/CCDrawNode.cpp:256
Can anyone help me?
Thank you!
jonseg
2
Maybe is a memory problem?
what version of cocos2d-x? What OS?
jonseg
4
The version is 3.3 and only happens on Android. On iOS works perfectly.
I use calls to an webservice with HttpRequest, something like this:
void APIManager::getRoutes(int state_id){
loadingModal = LoadingModal::create(getRootNode());
cocos2d::network::HttpRequest* request = new cocos2d::network::HttpRequest();
request->setUrl(ROUTES_API.c_str());
request->setRequestType(cocos2d::network::HttpRequest::Type::POST);
request->setResponseCallback(CC_CALLBACK_2(APIManager::onHttpRequestCompleted, this));
// write the post data
std::stringstream postData;
postData << "state_id=" << state_id;
request->setRequestData(postData.str().c_str(), postData.str().length());
request->setTag("routes");
cocos2d::network::HttpClient::getInstance()->send(request);
request->release();
}
void APIManager::onHttpRequestCompleted(HttpClient *sender, HttpResponse *response)
{
loadingModal->dismissModalCallback();
if (!response || !response->isSucceed())
{
this->onHttpRequestError("Connection error");
return;
}
std::vector<char> *buffer = response->getResponseData();
std::string strC(buffer->begin(), buffer->end());
rapidjson::Document jsonResponse;
jsonResponse.Parse<0>(strC.c_str());
if (jsonResponse.HasParseError())
{
this->onHttpRequestError("Connection error.");
return;
}
if(jsonResponse.IsObject() && jsonResponse.HasMember("error_code")){
this->onHttpRequestError("Connection error.");
return;
}
else if(jsonResponse.IsObject() || jsonResponse.IsArray()){
// correct
_eventCallback(EventType::ON_SUCCESS, strC.c_str());
}
else{
this->onHttpRequestError("Connection error.");
return;
}
}
“loadingModal” is a Sprite with a LoadingBar.
I suspect that the HttpRequest doesn’t close and causes a memory leak. Is possible?
Thank you very much!
jonseg
5
Maybe do I need to instance HttpRequest once when app starts and destroy when app ends?
Now, I call:
cocos2d::network::HttpRequest* request = new cocos2d::network::HttpRequest();
on every APIManager method where I do a request to the webservice.
Thank you.