If this is covered in another forum thread, please point me to it. I’ve looked but not found anything yet.
The problem I am running into is one of random crashes when pressing buttons on the controller. I followed the same model as the other input devices (e.g. touch, keypad), so in theory, they should have the same problem I’m seeing.
After adding a good amount of logging, I have discovered the root cause.
The main application thread sits in a loop and calls the director’s mainloop function. This function calls drawScene and then pops the current shared pool manager. This happens over and over, free-running.
The only solution I can think of is to provide some sort of synchronization object between the main app thread and any JNI thread. Even adding reference counts into the autorelease objects won’t help, because the retain and release methods in CCObject do not use atomic incs and decs, so the bad multi-threading demon raises its head when accessed from multiple threads at once.
Has anyone seen this problem? I have to assume so, since it’s a basic flaw in the path from Java to C*+ JS with the main app loop running in parallel.
So, more importantly, is there any known solution? I’m leaning toward a global mutex to synchronize the two parts of code, but I’d prefer something more elegant if possible.
I’ve attached a file showing the logging for one crash. I hope most of it is self-explanatory. The a… b… c…, etc lines are scattered through js_callFunc. The “e…” and “f…” ones bracket the call to CCCallFuncN::create.
Any help or thoughts appreciated! Thanks much.
TextFile14.txt.zip (18.9 KB)