8000 Add static bound for add_fd_with_callback · Issue #504 · rust-mobile/ndk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add static bound for add_fd_with_callback #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yyy33 opened this issue Apr 30, 2025 · 0 comments
Open

Add static bound for add_fd_with_callback #504

yyy33 opened this issue Apr 30, 2025 · 0 com 6EDF ments

Comments

@yyy33
Copy link
yyy33 commented Apr 30, 2025

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);
        })?;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0