Skip to content

Load Jetson multimedia libraries at runtime instead of linking them - #1365

Open
stephen-derosa wants to merge 2 commits into
mainfrom
sderosa/BOT-530-dont-force-link-jetson
Open

Load Jetson multimedia libraries at runtime instead of linking them#1365
stephen-derosa wants to merge 2 commits into
mainfrom
sderosa/BOT-530-dont-force-link-jetson

Conversation

@stephen-derosa

@stephen-derosa stephen-derosa commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Overview

The Jetson MMAPI backend hard-linked libnvv4l2, libnvbufsurface and libv4l2,
so an aarch64 binary built with Jetson support failed to load on non-Jetson ARM
systems — the loader errors out before JetsonVideoEncoderFactory::IsSupported()
ever runs. It also pinned the build host's L4T SONAMEs.

This applies the same Implib.so lazy-loading treatment CUDA and VAAPI already use:

  • Checked-in stubs for libv4l2.so / libnvbufsurface.so, generated from L4T r36.4.7.
  • jetson_runtime_loader.{h,cpp} — the stubs' dlopen callback (searches the L4T vendor
    dirs, tolerates SONAME drift) and a lk_jetson_runtime_libs_available() probe.
  • IsCodecSupported() and DmaBufVideoFrameBuffer::ToI420() check that probe before
    touching a lazily-bound symbol, since a stub aborts if its library is missing.
  • LK_JETSON_MMAPI_DIR overrides the hardcoded /usr/src/jetson_multimedia_api.

Result: one portable aarch64 binary that uses the Jetson encoder on L4T and falls back
elsewhere.

Breaking changes

None. The backend already required JetPack 5 / L4T R34+ — it calls NvBufSurfaceFromFd
unconditionally, and libnvbufsurface first ships in R34.1. The removed nvbuf_utils
link was vestigial: no symbol from it was ever referenced, and JetPack 6 no longer ships
that library at all.

Testing

In a linux/arm64 container with no Jetson libraries, against the real L4T r36.4.7
sources and libraries: the vendored MMAPI objects link with -Wl,--no-undefined and
DT_NEEDED lists only libstdc++/libgcc_s/libc; the probe reports unavailable and exits
cleanly without the libraries, and resolves trampolined calls correctly with them.

Target HW Testing

tested on HW, works as expected
./target/release/publisher --camera-index 0 --format mjpeg --width 2560 --height 720 --fps 30 --codec h264
Opening in BLOCKING MODE
Jetson MMAPI encoder is supported.
Opening in BLOCKING MODE
Jetson MMAPI AV1 encoder available.
Opening in BLOCKING MODE
Jetson MMAPI encoder is supported.
Using Jetson MMAPI encoder for H264
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 66 Level = 31
NVMEDIA: Need to set EMC bandwidth : 846000
875967048
842091865
875967048
842091865
NvVideo: bBlitMode is set to TRUE
LK_DUMP_H264 not set; skipping H264 dump (MMAPI).
875967048
842091865
875967048
842091865
875967048
842091865
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 66 Level = 31
NVMEDIA: Need to set EMC bandwidth : 846000
875967048

@github-actions

Copy link
Copy Markdown
Contributor

Changeset ✓

This PR includes a changeset covering all affected packages:

Package Bump
libwebrtc patch
livekit patch
livekit-ffi patch
webrtc-sys patch

@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 potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

This comment was marked as resolved.

@stephen-derosa
stephen-derosa force-pushed the sderosa/BOT-530-dont-force-link-jetson branch 2 times, most recently from 98cd792 to fad0e39 Compare August 26, 2026 23:18
@stephen-derosa
stephen-derosa requested review from chenosaurus and a lite review from Copilot August 27, 2026 21:07

This comment was marked as resolved.

stephen-derosa and others added 2 commits September 3, 2026 13:47
…The Jetson MMAPI backend hard-linked libnvv4l2, libnvbufsurface and libv4l2, so an aarch64 binary built with Jetson support failed to load on non-Jetson ARM systems with cannot open shared object file before any LiveKit code ran — the existing JetsonVideoEncoderFactory::IsSupported probe never got a chance to run.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@stephen-derosa
stephen-derosa force-pushed the sderosa/BOT-530-dont-force-link-jetson branch from 3cc459c to c4e1d5c Compare September 3, 2026 17:47
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