Description
I have just done a lovely 4 hour debugging session to find a panic. Because java + rust + tokio sucks ass, backtraces were invalid.
Anyhow, I do not know how nobody had this problem yet, because as soon as you connect to a Peripheral
, one would have noticed that it panics inside jni-utils
.
To be more precise this unwrap on a None value:
https://github.com/deviceplug/jni-utils-rs/blob/1737fd69e8d980ec045df6daafef250f2dd07ebd/rust/future.rs#L42
JFuture::from_env
is being called here:
btleplug/src/droidplug/jni/objects.rs
Line 150 in c227cc1
The classcache
gets populated here:
https://github.com/deviceplug/jni-utils-rs/blob/1737fd69e8d980ec045df6daafef250f2dd07ebd/rust/ops.rs#L382-L393
and this ops::init
function is being called automatically if jni_utls::init(env)
is called.
Note that btleplug
s droidplug
uses one of these classes in connect:
Lio/github/gedgygedgy/rust/future/Future
BUT droidplug
never called jni_utils::init
. In the droidplug::init
function and the following call to self::jni
only the btleplug classes get added to the classcache:
btleplug/src/droidplug/jni/mod.rs
Lines 27 to 53 in c227cc1
But jni_utils::init
is never called and therefore the classcache is missing all these classes:
https://github.com/deviceplug/jni-utils-rs/blob/1737fd69e8d980ec045df6daafef250f2dd07ebd/rust/ops.rs#L384-L393
... which leads to total failure. To fix this, droidplug::init
only has to also call jni_utils::init
and everything works fine....