Yes, it could be the thread issue. You can apple callback to rendertexture or perform in cocos-thread.
And BTW you can directly call this FileUtils::getInstance()->getWritablePath()
You dont need to call JNI method for that.
@Marce Yes it’s most likely a thread-related issue, so try out Scheduler::performFunctionInCocosThread(...) to handle it, as @smitpatel88 mentioned, or you could also try Node::scheduleOnce(...) to run the screenshot on the next update loop.
@smitpatel88getWritablePath() is overriden in the Android implementation of FileUtils, so calling FileUtils::getInstance()->getWritablePath() is actually calling FileUtilsAndroid::getWritablePath(), which internally calls the JNI method.
I’m not quite sure that I understand what you mean, because the code @Marce pasted is Cocos2d engine code, not user code, and the screenshot doesn’t show any user code calling FileUtilsAndroid::getWritablePath() directly:
string FileUtilsAndroid::getWritablePath() const
{
// Fix for Nexus 10 (Android 4.2 multi-user environment)
// the path is retrieved through Java Context.getCacheDir() method
string dir("");
string tmp = JniHelper::callStaticStringMethod("org.cocos2dx.lib.Cocos2dxHelper", "getCocos2dxWritablePath");
if (tmp.length() > 0)
{
dir.append(tmp).append("/");
return dir;
}
else
{
return "";
}
}
I’m assuming the getWritablePath() call in the callstack is coming from here, since Marce mentioned the use of RenderTexture::saveToFile:
Hi all, I’ve found the problem. It was a non-initialised pointer in a java class while trying to log the event into Firebase.
It was not a thread safe problem or any other problem inside RenderTexture.
I wonder why RenderTexture was affected though.
Sorry for the noise and thank you for the suggestions