Bithack / principia

Open source physics-based sandbox game.
https://principia-web.se
Other
258 stars 25 forks source link

lua: game:prompt() function is broken in Android #84

Open ManEnfu opened 1 year ago

ManEnfu commented 1 year ago

How to reproduce

Place LUA Script object and write:

function init(is_sandbox)
    game:prompt("Hello", "ok", "cancel")
end
function step(count)
end

Expected behavior

A prompt is displayed with message Hello and options ok and cancel

Resulted behavior

The prompt has empty message, and the only option available display the entire script, which can crash the game.

Screenshot_20230213-144539_Principia

rollerozxa commented 1 year ago

Can reproduce.

Screenshot_20230213-113718~2

Worth noting the regular prompt object still works so the Lua implementatiom must be doing something differently that broke somehow.

griffi-gh commented 1 year ago

Sometimes I don't even see the window, game:prompt straight up crashes the game for me.
But when it "works", the ok option doesn't crash the game
(Android 13/OneUI5.1)

griffi-gh commented 1 year ago

likely caused by ui.c:859

void
ui::open_dialog(int num, void *data/*=0*/)
{
    JNIEnv *env = Android_JNI_GetEnv();
    jclass cls = Android_JNI_GetActivityClass();

    jmethodID mid = env->GetStaticMethodID(cls, "open_dialog", "(IZ)V");

    if (mid) {
        env->CallStaticVoidMethod(cls, mid, (jvalue*)(jint)num, (jboolean)(data ? true : false));
    }
}
griffi-gh commented 6 months ago

is this still broken?

rollerozxa commented 6 months ago

I assume so, I don't think there's been any changes made that would have fixed this.