Repository navigation
fix(android): prevent app crashes when USB devices disconnect - #43
Conversation
|
|
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Apply rustfmt formatting to the Android serial compatibility code and desktop API test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 13 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/jni-bridge/.gitignore">
<violation number="1" location="tests/jni-bridge/.gitignore:2">
P2: Ignoring this standalone harness's `Cargo.lock` lets its floating dependencies resolve differently over time, making regression results less reproducible. Remove this ignore so the harness lockfile can be committed.</violation>
</file>
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
View guided diff | Re-trigger cubic
| @@ -0,0 +1,2 @@ | |||
| /target/ | |||
| /Cargo.lock | |||
There was a problem hiding this comment.
P2: Ignoring this standalone harness's Cargo.lock lets its floating dependencies resolve differently over time, making regression results less reproducible. Remove this ignore so the harness lockfile can be committed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/jni-bridge/.gitignore, line 2:
<comment>Ignoring this standalone harness's `Cargo.lock` lets its floating dependencies resolve differently over time, making regression results less reproducible. Remove this ignore so the harness lockfile can be committed.</comment>
<file context>
@@ -0,0 +1,2 @@
+/target/
+/Cargo.lock
</file context>
|
Thanks a lot for this PR — really solid work. The root cause and the fix were spot on: pending Java exceptions after a failed USB JNI call were escaping during native-thread teardown and crashing the Android app on dongle unplug/reconnect. Clearing/mapping those exceptions in After merge we followed up on the CI/tooling side that was blocking the green check:
This shipped in v3.0.8 / v3.0.9 ( |
USB unplug can terminate an Android app when reconnect tries to open the removed device.
openDeviceFdthrows a Java exception, butwith_envpreviously returned through?before clearing it. The pending exception then escapes native-thread teardown as an uncaught Android exception.This change always clears and maps pending Java exceptions before returning a JNI result, including exceptions raised while reading the original exception message. It also rejects I/O and control operations on closed USB handles, preventing stale adapter clones from panicking on endpoints cleared during detach.
Validation:
ExecutionException: IOException: device not foundfailure.The JNI harness runs independently of desktop Tauri/WebView dependencies:
cargo test --manifest-path tests/jni-bridge/Cargo.toml(requires a JDK andJAVA_HOME).Summary by cubic
Prevents Android crashes when USB devices disconnect. The JNI bridge now clears and maps pending Java exceptions before returning from failed USB operations, so they no longer escape during native-thread teardown. Closed serial handles reject I/O and control operations with
Disconnectedinstead of panicking in stale adapter clones.Bug Fixes
Disconnectedfor read/write, line and flow control, DTR/RTS, break, purge, and reader setup.tests/jni-bridgethat runs in CI on Ubuntu (cargo test --manifest-path tests/jni-bridge/Cargo.toml, requires a JDK).Written for commit ff01912. Summary will update on new commits.