Skip to content

Conversation

@Sqhh99
Copy link
Contributor

@Sqhh99 Sqhh99 commented Dec 31, 2025

Summary

This PR:

  1. Resolves the corrupted size vs. prev_size heap corruption error on Linux debug builds
  2. Fixes the release workflow to correctly build and publish SDK artifacts

Problem

Debug-built examples crash on Linux:

corrupted size vs. prev_size
Aborted (core dumped)

Root Cause: Statically linking liblivekit_ffi.a mixes Debug C++ code with Release libwebrtc code, causing ABI incompatibilities and heap corruption.

Solution

Use dynamic library linking (.so/.dylib) on Linux/macOS, matching the Windows DLL architecture.

Key Changes:

  • Dramatically Reduced Size: SDK package reduced from ~400MB to ~40MB (release builds only; users can build debug locally or this can be added later)
  • ABI Isolation: Rust/libwebrtc code runs in its own address space, preventing Debug/Release mixing
  • Independent Memory Management: Each library uses its own allocator
  • Consistent Architecture: Same approach across Windows, Linux, and macOS

Note: When linking, liblivekit.a must be linked before liblivekit_ffi.so:

target_link_libraries(your_app PRIVATE livekit livekit_ffi)

SDK Release Structure

livekit-sdk-linux-x64-{version}/
├── bin/                              # Example executables + runtime dependencies
│   ├── SimpleRoom, SimpleRpc, SimpleDataStream
│   ├── liblivekit_ffi.so, libSDL3.so.0
│   └── data/
├── include/livekit/                  # Public headers
└── lib/
    ├── liblivekit.a                  # Static C++ wrapper
    └── liblivekit_ffi.so             # Rust FFI shared library

livekit-sdk-macos-arm64-{version}/    # Similar structure with .dylib
livekit-sdk-windows-x64-{version}/    # Similar structure with .dll

Changed Files

File Lines Description
.github/workflows/builds.yml 2 Minor CI path fix
.github/workflows/make-release.yml 107 Include bin/ directory with examples; fix double-compression; use versioned artifact names
CMakeLists.txt 106 Use SHARED IMPORTED for livekit_ffi on Unix; add RPATH settings; copy .so/.dylib to output
DEPENDENCIES.md 18 Update for dynamic library usage and deployment requirements
README.md 4 Add .so/.dylib deployment note
README_BUILD.md 37 Update build output structure documentation
examples/CMakeLists.txt 70 Add RPATH for examples; copy SDL3 shared library; create SONAME symlink on Linux
examples/cmake/sdl3.cmake 40 SDL3 FetchContent configuration updates

Testing

Platform Debug Release
Linux x64
macOS arm64 -
Windows x64

Sqhh99 added 6 commits January 1, 2026 00:15
- Simplify lib output: remove platform/config subdirectories
  (build-debug/release already provides separation)
- Prevent SDL3 from polluting lib directory (build to _deps/)
- Fix protobuf debug DLL naming (libprotobufd.dll)
- Sync make-release.yml Linux deps with builds.yml
- Remove macos-x64 cross-compile from release (keep arm64 only)
…heap corruption

- Add RPATH settings ($ORIGIN for Linux, @executable_path for macOS)
- Change livekit_ffi from static (.a) to shared library (.so/.dylib)
- Add IMPORTED_NO_SONAME to ensure relative path linking
- Copy shared library to examples bin directory
- Update make-release.yml to include bin directory with examples
- Fix double-compression issue in release workflow
This resolves the 'corrupted size vs. prev_size' error on Linux debug builds
by isolating the Rust/libwebrtc code behind a shared library boundary,
matching the Windows DLL architecture.
Release workflow:
- Remove pre-compression in build jobs to avoid artifact double-zip
- Move archive creation to release job (tar.gz for Unix, zip for Windows)
- Include bin directory with example executables
Documentation:
- Update DEPENDENCIES.md for dynamic library usage
- Update README_BUILD.md with new build output structure
- Update README.md with .so/.dylib deployment requirements
- Set RPATH to \$ORIGIN for examples to load libs from bin directory
- Create libSDL3.so.0 -> libSDL3.so.0.x.x symlink on Unix
- Copy SDL3 shared library on all platforms
- Use versioned artifact names in release workflow for cleaner structure
- macOS dylib versioning doesn't use SONAME symlinks like Linux .so files.
- Creating a symlink with the same source and target causes ELOOP error.
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