ndk icon indicating copy to clipboard operation
ndk copied to clipboard

Add static bound for add_fd_with_callback

Open yyy33 opened this issue 8 months ago • 0 comments

Since the callback is leaking into memory, should we add a 'static constraint to it to make sure it's always valid, otherwise a JNIEnv <'local> is captured here, and it compiles. But the JNIEnv is only valid in the scope of the native method on_create

//native jni method
pub fn on_create(mut env: JNIEnv, jactivity: JObject) {
    ThreadLooper::for_thread()
        .unwrap()
        .add_fd_with_callback(fd, FdEvent::INPUT, move || {
            env.call_method(obj, name, sig, args);
        })?;
}

yyy33 avatar Apr 30 '25 01:04 yyy33