fix(moq-video): NVENC falls back instead of aborting when no NVIDIA driver#1825
Closed
kixelated wants to merge 1 commit into
Closed
fix(moq-video): NVENC falls back instead of aborting when no NVIDIA driver#1825kixelated wants to merge 1 commit into
kixelated wants to merge 1 commit into
Conversation
…ting cudarc and the NVENC SDK dlopen their driver libraries lazily and panic (which aborts the process under release's `panic = "abort"`) when the library is absent. So on a GPU-less Linux host, Kind::Auto/Hardware crashed in `CudaContext::new` instead of falling back to openh264, contrary to the documented behavior. Probe libcuda and libnvidia-encode with libloading before touching either crate, and return Error::Codec when a library is missing so backend::open moves on to the next candidate. Adds a Linux/nvenc test asserting open() errors (rather than panics) when the driver is absent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
Folded into #1819 (commit b0e7682): that PR makes hardware encoders always-on, which is what turns this NVENC panic into a crash on every GPU-less Linux box, so the fallback fix belongs there rather than as a separate PR racing it. Same probe (libcuda + libnvidia-encode via libloading) + the GPU-less test, adapted to the always-on dep layout (libloading as a non-optional target.linux dep). Verified in podman: (Written by Claude) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a Linux host with no NVIDIA driver,
moq-video's NVENC backend aborts the process instead of falling back to software. cudarc (CudaContext::new) and the NVENC SDK both dlopen their driver libraries lazily andpanic!when the library is missing (cudarc'spanic_no_lib_found, the SDK's "failed to dlopen the NVIDIA encode library"). Under release'spanic = "abort"that panic aborts; in tests (Cargo forces unwind) it shows up as a hard test failure.So
Kind::Auto/Kind::Hardware— the default formoq-cli capture— crashes on any GPU-less Linux box, contrary to the documented "falls back to software (see backend::open)" behavior.This was surfaced by a
Kind::Autoround-trip test in #1802 panicking on the GPU-less CI runner.Fix
Probe the driver libraries with
libloadingbefore calling into cudarc / the SDK, and returnError::Codecif either is absent sobackend::openmoves on to the next candidate (openh264):libcuda.so.1/libcuda.so(cudarc's CUDA driver), andlibnvidia-encode.so.1/libnvidia-encode.so(matches the SDK's own candidate list).A pre-check (not
catch_unwind) is required because release builds usepanic = "abort", wherecatch_unwindcan't help.libloadingis added as annvenc-feature-gated optional dep, mirroring the existingcudarc/nvidia-video-codec-sdkgating.Test plan
cargo fmt --checkclean; non-NVENCcargo build -p moq-videounaffected (macOS).#[cfg(all(target_os = "linux", feature = "nvenc"))]testmissing_driver_errors_instead_of_panicking: on a host without the driver,Nvenc::openreturnsErrrather than panicking. This runs on the GPU-less Linux CI runner (cargo test -p moq-video --all-features), which is exactly where the abort happened before.cfg(linux)path locally (macOS box; nix/rustup cross-toolchain split blocked a zigbuild). Relying on the Linux CI runner to compile + run the new test.Note
VAAPI (
moq-vaapi, dlopen'd libva) may have the same panic-on-missing-library shape; if so,Kind::Autowould still abort at the VAAPI candidate after NVENC falls back. Worth a follow-up check, but out of scope here.(Written by Claude)