Skip to content
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

fix: handle JNI java exceptions properly in client_core #2563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShootingKing-AM
Copy link
Member

TLDR

ALVR panicked: What happened:
panicked at alvr\system_info\src\android.rs:37:17:
Java Exception Occured: java.lang.SecurityException: WifiService: Neither user 10165 nor current process has android.permission.CHANGE_WIFI_MULTICAST_STATE

After using the PR

02:51:34.878 11648-11648 System.err              viritualisres.phonevr                W  java.lang.SecurityException: WifiService: Neither user 10165 nor current process has android.permission.CHANGE_WIFI_MULTICAST_STATE.
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Parcel.createException(Parcel.java:2357)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Parcel.readException(Parcel.java:2340)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Parcel.readException(Parcel.java:2282)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.net.wifi.IWifiManager$Stub$Proxy.acquireMulticastLock(IWifiManager.java:2634)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.net.wifi.WifiManager$MulticastLock.acquire(WifiManager.java:4762)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at viritualisres.phonevr.ALVRActivity.initializeNative(Native Method)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at viritualisres.phonevr.ALVRActivity.onCreate(ALVRActivity.java:108)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.Activity.performCreate(Activity.java:8000)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.Activity.performCreate(Activity.java:7984)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
02:51:34.892 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Handler.dispatchMessage(Handler.java:106)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.os.Looper.loop(Looper.java:223)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ActivityThread.main(ActivityThread.java:7656)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at java.lang.reflect.Method.invoke(Native Method)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  Caused by: android.os.RemoteException: Remote stack trace:
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ContextImpl.enforce(ContextImpl.java:2018)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2046)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:851)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at com.android.server.wifi.WifiServiceImpl.enforceMulticastChangePermission(WifiServiceImpl.java:720)
02:51:34.893 11648-11648 System.err              viritualisres.phonevr                W  	at com.android.server.wifi.WifiServiceImpl.acquireMulticastLock(WifiServiceImpl.java:3370)
02:51:36.142 11648-11648 [ALVR NATIVE-RUST]      viritualisres.phonevr                E  ALVR panicked: What happened:
                                                                                         panicked at alvr\system_info\src\android.rs:37:17:
                                                                                         Java Exception Occured: java.lang.SecurityException: WifiService: Neither user 10165 nor current process has android.permission.CHANGE_WIFI_MULTICAST_STATE.
                                                                                         
                                                                                         Backtrace:
                                                                                            0: alvr_common::logging::set_panic_hook::{{closure}}
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\common\src\logging.rs:191:13
                                                                                            1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/alloc/src/boxed.rs:1984:9
                                                                                               std::panicking::rust_panic_with_hook
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:825:13
                                                                                            2: std::panicking::begin_panic_handler::{{closure}}
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:690:13
                                                                                            3: std::sys::backtrace::__rust_end_short_backtrace
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/sys/backtrace.rs:170:18
                                                                                            4: rust_begin_unwind
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:681:5
                                                                                            5: core::panicking::panic_fmt
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/core/src/panicking.rs:75:14
                                                                                            6: alvr_system_info::android::env_call_method_handled::{{closure}}
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:37:17
                                                                                            7: core::result::Result<T,E>::map_err
                                                                                                      at C:\Users\user\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library/core/src\result.rs:856:27
                                                                                            8: alvr_system_info::android::env_call_method_handled
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:20:5
                                                                                            9: alvr_system_info::android::set_wifi_lock::set_lock
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:174:9
                                                                                           10: alvr_system_info::android::set_wifi_lock
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:226:5
                                                                                           11: alvr_client_core::ClientCoreContext::new
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\client_core\src\lib.rs:98:13
                                                                                           12: alvr_initialize
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\client_core\src\c_api.rs:298:40
                                                                                           13: Java_viritualisres_phonevr_ALVRActivity_initializeNative
                                                                                                      at D:/Users/Documents/GitHub/PhoneVR/code/mobile/android/PhoneVR/app/.cxx/Debug/3k205by4/x86/D:/Users/Documents/GitHub/PhoneVR/code/mobile/android/PhoneVR/app/src/main/cpp/alvr_main.cpp:211:5
                                                                                           14: art_quick_generic_jni_trampoline
                                                                                           15: art_quick_invoke_stub
                                                                                           16: _ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc
                                                                                           17: _ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_11ShadowFrameEtPNS_6JValueE
                                                                                           18: _ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           19: MterpInvokeDirect
                                                                                           20: mterp_op_invoke_direct
                                                                                           21: MterpInvokeVirtual
                                                                                           22: mterp_op_invoke_virtual
                                                                                           23: MterpInvokeVirtual
                                                                                           24: mterp_op_invoke_virtual
                                                                                           25: MterpInvokeVirtual
                                                                                           26: mterp_op_invoke_virtual
                                                                                           27: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           28: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           29: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           30: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           31: ExecuteSwitchImplAsm
                                                                                           32: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
02:51:36.142 11648-11648 [ALVR NATIVE-RUST]      viritualisres.phonevr                E    33: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           34: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           35: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           36: ExecuteSwitchImplAsm
                                                                                           37: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           38: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           39: _ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           40: MterpInvokeVirtual
                                                                                           41: mterp_op_invoke_virtual
                                                                                           42: MterpInvokeVirtual
                                                                                           43: mterp_op_invoke_virtual
                                                                                           44: MterpInvokeVirtual
                                                                                           45: mterp_op_invoke_virtual
                                                                                           46: MterpInvokeVirtual
                                                                                           47: mterp_op_invoke_virtual
                                                                                           48: MterpInvokeVirtual
                                                                                           49: mterp_op_invoke_virtual
                                                                                           50: MterpInvokeVirtual
                                                                                           51: mterp_op_invoke_virtual
                                                                                           52: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           53: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           54: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           55: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           56: ExecuteSwitchImplAsm
                                                                                           57: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           58: _ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameE
                                                                                           59: artQuickToInterpreterBridge
                                                                                           60: art_quick_to_interpreter_bridge
                                                                                           61: art_quick_invoke_static_stub
                                                                                           62: _ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc
                                                                                           63: _ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j
                                                                                           64: _ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_P13_jobjectArray
                                                                                           

before

03:09:12.419 13602-13602 [ALVR NATIVE-RUST]      viritualisres.phonevr                E  ALVR panicked: What happened:
                                                                                         panicked at alvr\system_info\src\android.rs:144:10:
                                                                                         called `Result::unwrap()` on an `Err` value: JavaException
                                                                                         
                                                                                         Backtrace:
                                                                                            0: alvr_common::logging::set_panic_hook::{{closure}}
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\common\src\logging.rs:191:13
                                                                                            1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/alloc/src/boxed.rs:1984:9
                                                                                               std::panicking::rust_panic_with_hook
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:825:13
                                                                                            2: std::panicking::begin_panic_handler::{{closure}}
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:690:13
                                                                                            3: std::sys::backtrace::__rust_end_short_backtrace
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/sys/backtrace.rs:170:18
                                                                                            4: rust_begin_unwind
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/std/src/panicking.rs:681:5
                                                                                            5: core::panicking::panic_fmt
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/core/src/panicking.rs:75:14
                                                                                            6: core::result::unwrap_failed
                                                                                                      at /rustc/c44b3d50fea96a3e0417e8264c16ea21a0a3fca2/library/core/src/result.rs:1699:5
                                                                                            7: core::result::Result<T,E>::unwrap
                                                                                                      at C:\Users\user\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library/core/src\result.rs:1104:23
                                                                                               alvr_system_info::android::set_wifi_lock::set_lock
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:138:9
                                                                                            8: alvr_system_info::android::set_wifi_lock
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\system_info\src\android.rs:190:5
                                                                                            9: alvr_client_core::ClientCoreContext::new
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\client_core\src\lib.rs:98:13
                                                                                           10: alvr_initialize
                                                                                                      at D:\Users\Documents\GitHub\PhoneVR\code\mobile\android\PhoneVR\ALVR\alvr\client_core\src\c_api.rs:298:40
                                                                                           11: Java_viritualisres_phonevr_ALVRActivity_initializeNative
                                                                                                      at D:/Users/Documents/GitHub/PhoneVR/code/mobile/android/PhoneVR/app/.cxx/Debug/3k205by4/x86/D:/Users/Documents/GitHub/PhoneVR/code/mobile/android/PhoneVR/app/src/main/cpp/alvr_main.cpp:211:5
                                                                                           12: art_quick_generic_jni_trampoline
                                                                                           13: art_quick_invoke_stub
                                                                                           14: _ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc
                                                                                           15: _ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_11ShadowFrameEtPNS_6JValueE
                                                                                           16: _ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           17: MterpInvokeDirect
                                                                                           18: mterp_op_invoke_direct
                                                                                           19: MterpInvokeVirtual
                                                                                           20: mterp_op_invoke_virtual
                                                                                           21: MterpInvokeVirtual
                                                                                           22: mterp_op_invoke_virtual
                                                                                           23: MterpInvokeVirtual
                                                                                           24: mterp_op_invoke_virtual
                                                                                           25: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           26: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           27: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           28: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           29: ExecuteSwitchImplAsm
                                                                                           30: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           31: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           32: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
03:09:12.420 13602-13602 [ALVR NATIVE-RUST]      viritualisres.phonevr                E    33: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           34: ExecuteSwitchImplAsm
                                                                                           35: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           36: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           37: _ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           38: MterpInvokeVirtual
                                                                                           39: mterp_op_invoke_virtual
                                                                                           40: MterpInvokeVirtual
                                                                                           41: mterp_op_invoke_virtual
                                                                                           42: MterpInvokeVirtual
                                                                                           43: mterp_op_invoke_virtual
                                                                                           44: MterpInvokeVirtual
                                                                                           45: mterp_op_invoke_virtual
                                                                                           46: MterpInvokeVirtual
                                                                                           47: mterp_op_invoke_virtual
                                                                                           48: MterpInvokeVirtual
                                                                                           49: mterp_op_invoke_virtual
                                                                                           50: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           51: _ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameEPNS_6JValueE
                                                                                           52: _ZN3art11interpreter6DoCallILb0ELb1EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE
                                                                                           53: _ZN3art11interpreter20ExecuteSwitchImplCppILb1ELb0EEEvPNS0_17SwitchImplContextE
                                                                                           54: ExecuteSwitchImplAsm
                                                                                           55: _ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16375758241455872412
                                                                                           56: _ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadERKNS_20CodeItemDataAccessorEPNS_11ShadowFrameE
                                                                                           57: artQuickToInterpreterBridge
                                                                                           58: art_quick_to_interpreter_bridge
                                                                                           59: art_quick_invoke_static_stub
                                                                                           60: _ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc
                                                                                           61: _ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j
                                                                                           62: _ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_P13_jobjectArray
                                                                                           

@ShootingKing-AM ShootingKing-AM changed the title fix: handle JNI java exception properly in client_core fix: handle JNI java exceptions properly in client_core Dec 8, 2024
@ShootingKing-AM ShootingKing-AM marked this pull request as draft December 8, 2024 21:44
@ShootingKing-AM ShootingKing-AM marked this pull request as ready for review December 9, 2024 01:55
Comment on lines +13 to +19
fn env_call_method_handled<'local>(
env: &mut JNIEnv<'local>,
object: &JObject,
method: &str,
sig: &str,
args: &[JValue],
) -> Result<JValueOwned<'local>, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually i follow the path of fewer parameters when making a function to abstract away some code. In this case it would be much easier to make a function taking a jni::Result<T> and return a anyhow::Result<T>. Inside the function, don't panic because you don't know the intention of the caller, even if we always unwrap, don't expect anything. Instead limit this function to just transform the error.

Actually, before doing this, check if just calling .to_any() at the caller site is enough (with the purpose of making the error message clearer). This function is defined in alvr_common. Other things you could do is to play with different printing methods (using {} or {:?} placeholders with format!())

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

Successfully merging this pull request may close these issues.

2 participants