Skip to content

jni: release the receive loop's global refs and clear callback exceptions - #288

Open
ehoeve786 wants to merge 1 commit into
softwiredtech:mainfrom
ehoeve786:fix/jni-receive-loop-refs
Open

ehoeve786 wants to merge 1 commit into
softwiredtech:mainfrom
ehoeve786:fix/jni-receive-loop-refs

Conversation

@ehoeve786

Copy link
Copy Markdown
Collaborator

nativeStartReceiveLoop created global refs to the Kotlin callback and the output buffer on every start and never deleted them, so each comma connect/disconnect cycle leaked the callback lambda and, through it, the CommaDataSource and its flows. It also never checked for an exception after CallVoidMethod; one thrown by the callback stayed pending into the next JNI call, which CheckJNI aborts on. Delete the refs when the loop ends, and describe + clear a pending exception after each callback.

Testing

  • Android builds and the unit tests pass.
  • Not run on a device: this path needs a comma device on the same network, which my setup doesn't have connected.

🤖 Generated with Claude Code

…ions

nativeStartReceiveLoop created global refs to the Kotlin callback and the
output buffer on every start and never deleted them, so each comma
connect/disconnect cycle leaked the callback lambda and, through it, the
CommaDataSource and its flows. It also never checked for an exception after
CallVoidMethod; one thrown by the callback stayed pending into the next JNI
call, which CheckJNI aborts on. Delete the refs when the loop ends, and
describe + clear a pending exception after each callback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant