xperia64 / android-mkxp

A port of MKXP and its dependencies to Android
18 stars 21 forks source link

Black screen if opened after clean exit #11

Open pulsejet opened 7 years ago

pulsejet commented 7 years ago

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.

Ancurio commented 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).

pulsejet commented 7 years ago

@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)

xperia64 commented 7 years ago

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.

pulsejet commented 7 years ago

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.

xperia64 commented 7 years ago

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.

Ancurio commented 7 years ago

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).