Skip to content

fix: keep strings intact across JNI and bind both AudioResampler initializers - #512

Merged
devopvoid merged 1 commit into
mainfrom
fix/jni-string-conversion
Nov 1, 2026
Merged

devopvoid merged 1 commit into
mainfrom
fix/jni-string-conversion

Conversation

@devopvoid

@devopvoid devopvoid commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner
  • Native strings came back through NewStringUTF, which takes Modified UTF-8: emoji and embedded NULs were mangled and empty strings became null (e.g. RTCDataChannel.getLabel()). JavaString now converts UTF-8 ⇄ UTF-16 itself and keeps "". null remains only where WebRTC encodes an absent value as empty or unset: transceiver mid, candidate sdpMid/serverUrl, unset ICE server credentials, the unexposed address of an ICE error event. RTCDtmfSender.tones() and the final onToneChange now return "", as documented.
  • Native error text (which carries track ids, SDP lines etc.) was used as the printf format of the thrown exception and went through NewStringUTF/ThrowNew. It is now an argument and converted the same way.
  • The JNI header lacked the long names of the overloaded AudioResampler.initialize, so initialize(int, int, int) had C++ linkage and bound to the parameterless function. Both are now initialize__ / initialize__III.

…ializers

Native strings went back through NewStringUTF, which takes Modified UTF-8,
so emoji and embedded NULs came back changed, and empty strings became
null. Convert UTF-8 to UTF-16 properly and keep "" as "", mapping to null
only where WebRTC encodes an absent value as empty or unset.

WebRTC's error text, which carries track ids and SDP lines, was used as
the printf format of the thrown exception and also reached Java in
Modified UTF-8. Pass it as an argument and convert it the same way.

The JNI header lacked the long names of the overloaded
AudioResampler.initialize, so initialize(int, int, int) had C++ linkage
and Java bound it to the parameterless function.
@devopvoid
devopvoid force-pushed the fix/jni-string-conversion branch from 3733bde to 3e9a14e Compare November 1, 2026 14:38
@devopvoid
devopvoid merged commit fe24fbd into main Nov 1, 2026
5 of 14 checks passed
@devopvoid
devopvoid deleted the fix/jni-string-conversion branch November 1, 2026 14:39
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