File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -925,6 +925,11 @@ pub unsafe extern "C" fn _rust_glue_entry(native_app: *mut ffi::android_app) {
925925 } ;
926926
927927 unsafe {
928+ // Name thread - this needs to happen here after attaching to a JVM thread,
929+ // since that changes the thread name to something like "Thread-2".
930+ let thread_name = std:: ffi:: CStr :: from_bytes_with_nul ( b"android_main\0 " ) . unwrap ( ) ;
931+ libc:: pthread_setname_np ( libc:: pthread_self ( ) , thread_name. as_ptr ( ) ) ;
932+
928933 let app = AndroidApp :: from_ptr ( NonNull :: new ( native_app) . unwrap ( ) , jvm. clone ( ) ) ;
929934
930935 // We want to specifically catch any panic from the application's android_main
Original file line number Diff line number Diff line change @@ -868,6 +868,11 @@ extern "C" fn ANativeActivity_onCreate(
868868 rust_glue. notify_main_thread_running ( ) ;
869869
870870 unsafe {
871+ // Name thread - this needs to happen here after attaching to a JVM thread,
872+ // since that changes the thread name to something like "Thread-2".
873+ let thread_name = std:: ffi:: CStr :: from_bytes_with_nul ( b"android_main\0 " ) . unwrap ( ) ;
874+ libc:: pthread_setname_np ( libc:: pthread_self ( ) , thread_name. as_ptr ( ) ) ;
875+
871876 // We want to specifically catch any panic from the application's android_main
872877 // so we can finish + destroy the Activity gracefully via the JVM
873878 catch_unwind ( || {
You can’t perform that action at this time.
0 commit comments