Skip to content

fix: keep JNI thread handling quiet and correct on JVM shutdown - #269

Merged
devopvoid merged 1 commit into
devopvoid:mainfrom
SendableMetatype:fix/jvm-shutdown-attach
Sep 6, 2026
Merged

fix: keep JNI thread handling quiet and correct on JVM shutdown#269
devopvoid merged 1 commit into
devopvoid:mainfrom
SendableMetatype:fix/jvm-shutdown-attach

Conversation

@SendableMetatype

@SendableMetatype SendableMetatype commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

When the JVM shuts down while libwebrtc threads are still running, their callbacks into Java fail to attach. The per-thread JNI helper then prints "Failed to attach thread" to stdout for each of them, and the log sink goes on to call into the null environment it got back.

This PR includes a commit by Joshua Castle (Kas-tle), who maintains a downstream fork of this library, kept under his authorship. It changes three things:

  • The helper remembers whether it attached the thread itself, and detaches only those. Before, the destructor detached every thread, including threads that were attached before the helper saw them.
  • When attaching fails, the helper leaves the environment null and prints nothing.
  • The log sink returns early when it gets a null environment instead of calling into it.

Validation on my fork: this run builds and tests on all six platforms.

@devopvoid
devopvoid merged commit ab74436 into devopvoid:main Sep 6, 2026
7 checks passed
@SendableMetatype
SendableMetatype deleted the fix/jvm-shutdown-attach branch September 6, 2026 12:06
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.

3 participants