Skip to content

Fixed data tracks failing to load in apps minified with R8 - #1023

Merged
davidliu merged 1 commit into
livekit:mainfrom
adrian-niculescu:fix/data-tracks-r8-jna-rules
Sep 16, 2026
Merged

davidliu merged 1 commit into
livekit:mainfrom
adrian-niculescu:fix/data-tracks-r8-jna-rules

Conversation

@adrian-niculescu

Copy link
Copy Markdown
Contributor

In an app built with R8 minification, data tracks never become available: publishDataTrack fails with "Data tracks are unavailable: the native library failed to load", and remote data tracks are never discovered. The log shows UnsatisfiedLinkError: Can't obtain peer field ID for class com.sun.jna.Pointer on the first join.

The data track bindings in livekit-uniffi-android call Rust through JNA. libjnidispatch resolves JNA's classes and fields by name, and JNA reads the bindings' Structure and Callback subclasses reflectively. Neither JNA's AAR nor livekit-uniffi-android ships keep rules (the latter's consumer-rules.pro is empty), so R8 renames or strips them. This adds the rules from JNA's FAQ to the SDK's consumer rules. They could also live in livekit-uniffi-android's consumer-rules.pro.

Tested with a minified release app that depends on the SDK and creates a RemoteDataTrackManager, on an Android 17 emulator: without the rules it fails with the error above, with them the manager is created and calls into the native library go through.

The data track bindings call Rust through JNA. libjnidispatch resolves JNA's
classes and fields by name, and JNA reads the bindings' Structure and Callback
subclasses reflectively, but neither JNA nor livekit-uniffi-android ships keep
rules, so R8 renamed or stripped them and the native library failed to load.
Added the rules from JNA's FAQ to the consumer rules.
@changeset-bot

changeset-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b09bea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
client-sdk-android Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@davidliu
davidliu merged commit 923ce1d into livekit:main Sep 16, 2026
6 checks passed
@davidliu davidliu mentioned this pull request Sep 16, 2026
@adrian-niculescu
adrian-niculescu deleted the fix/data-tracks-r8-jna-rules branch September 16, 2026 15:48
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.

2 participants