livekit / rust-sdks

LiveKit realtime and server SDKs for Rust
https://livekit.io
Apache License 2.0
185 stars 44 forks source link

Failing Rust SDK Examples #380

Closed edavalosanaya closed 1 month ago

edavalosanaya commented 1 month ago

First of all, great and amazing work from the LiveKit team! Thank y'all for all the time and effort you have put into this project.

As I have started working on integrating embedded device to join a LiveKit room session, I encountered some dependency issues and failing examples.

All of this testing was done on an Ubuntu 22.04 and using a local Livekit server, following the instructions found in LiveKit's Official Documentation.

All of my changes to make the examples to (somewhat) run can be found my personal fork.

Here are the issues in the tutorials:

  1. All examples require the livekit dependencies needed to be bumped to 0.4.1
  2. api example results in the following:
    
    $ LIVEKIT_URL=http://127.0.0.1:7880 LIVEKIT_API_KEY=devkey LIVEKIT_API_SECRET=secret cargo run -p api
    warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
    note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
    note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
    note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
    Compiling livekit-protocol v0.3.4 (/home/nicole/GitHub/external/rust-sdks/livekit-protocol)
    error[E0425]: cannot find function `spawn` in crate `livekit_runtime`
    --> /home/nicole/GitHub/external/rust-sdks/livekit-protocol/src/debouncer.rs:38:22
    |
    38 |     livekit_runtime::spawn(debounce_task(duration, future, rx, cancel_rx));
    |                      ^^^^^ not found in `livekit_runtime`
    |
    help: consider importing one of these items
    |
    15 + use std::thread::spawn;
    |
    15 + use tokio::spawn;
    |
    help: if you import `spawn`, refer to it directly
    |
    38 -     livekit_runtime::spawn(debounce_task(duration, future, rx, cancel_rx));
    38 +     spawn(debounce_task(duration, future, rx, cancel_rx));
    |
error[E0425]: cannot find function sleep in crate livekit_runtime --> /home/nicole/GitHub/external/rust-sdks/livekit-protocol/src/debouncer.rs:54:34 54 _ = livekit_runtime::sleep(duration) => { ^^^^^ not found in livekit_runtime
help: consider importing one of these items 15 + use std::thread::sleep;
15 + use tokio::time::sleep; help: if you import sleep, refer to it directly

54 - _ = livekitruntime::sleep(duration) => { 54 + = sleep(duration) => { |

For more information about this error, try rustc --explain E0425. error: could not compile livekit-protocol (lib) due to 2 previous errors

By forcing ``livekit-api`` to use ``livekit-runtime/tokio`` via changing the ``Cargo.toml``, the ``api`` example then successfully runs. 

3. 2 Line changes to ``basic_room`` to compile
4. ``basic_room_async`` works (but undo the monkey patch for the ``api`` example) and needs the same 2 lines changed like ``basic_room``
5. ``basic_room_dispatcher`` also needing the same 2 lines changes as other basic room examples.
6. ``play_from_disk`` results in the ``Invalid RIFF header`` using the provided example WAV file.
7. ``wgpu_room`` has to many errors and requires significant maintenance.

I was not able to successfully run ``save_to_disk`` due to invalid token (working this out). ``mobile`` is out of scope in terms of my work and interest.

Lastly but **extremely importantly**, all of these examples require relative LiveKit dependencies, like this: 
```toml
livekit = { path = "../../livekit", version = "0.4.1", features = ["native-tls"]}

Using the crates from crates.io fails as the libwebrtc crate cannot be found (as reported in Issue #357). Therefore, I was not able to run any example outside of the rusk-sdks without copying crates to my project (not ideal).

davidzhao commented 1 month ago

Thanks for the heads up, we'll update the examples