Open pulsejet opened 7 years ago
This is most likely due to libruby
not supporting reinitialization. Either that has to be fixed, or mkxp needs to be properly killed on shutdown (process must not linger on).
@Ancurio, will do. Just pushed a commit https://github.com/xperia64/android-mkxp/commit/e0acfca42e69283e644f473ae1d2c3fcdc3552a6 to my fork that fixes this by killing the app altogether on destroy. I have put the method right at the top of the procedure, so I don't guess that's right though... (but it works and I'm in a sorta hurry)
One other workaround which I've used in the past is not loading the library with Java's System.loadLibrary but instead using dlfcn to open the library and grab all the symbols. I can close and reopen the library as many times as needed. I don't know how many symbols I need to grab here, but it might be worth looking into.
I would still prefer to kill it at the end either way, since a running process which is no longer need is, after all, a waste.
Ideally, the actual C++ mkxp things should be shutdown/unloaded properly rather than hard killing the entire app, more similar to how Mupen64Plus-AE handles things.
Ideally, the actual C++ mkxp things should be shutdown/unloaded properly rather than hard killing the entire app, more similar to how Mupen64Plus-AE handles things.
Ah, right, in the Android/SDL world we're no longer mkxp
but libmkxp
. So if unloading and reloading that binary leads to all of the static data segments being reinitialized to zero (or their defaults), that should work for libruby
as well (assuming you statically link everything like I did).
Really the only reason the app process is not killed by Android is due to the assumption that a user might open up the app again soon after closing it. But when you explicitly quit the game, that's probably not going to happen. Besides, Android is very quick to kill a running-in-background mkxp anyway due to its high resource usage (something to also keep in mind).
If you close mkxp with a clean exit i.e. from inside of the game, and then do not clear it from recents, then it just shows a black screen when started again. If it is cleared from recents, then works as expected.