Skip to content

Wrap Tokio types in a configurable runtime - #310

Merged
theomonnom merged 15 commits into
livekit:mainfrom
zed-industries:cross-rt
Mar 28, 2024
Merged

theomonnom merged 15 commits into
livekit:mainfrom
zed-industries:cross-rt

Conversation

@mikayla-maki

@mikayla-maki mikayla-maki commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Adds a thin compatibility layer over the rust runtime ecosystem.

TODO:

  • Add support for async_std compatible runtimes
  • Resolve any TODOs
  • Get the async_std examples running
  • Make sure this works for Zed
  • Pass CI
  • Switch from async default to tokio default N/A, CI is currently broken

@CLAassistant

CLAassistant commented Feb 15, 2024

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mikayla-maki
mikayla-maki marked this pull request as ready for review February 27, 2024 00:02

@theomonnom theomonnom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice! lgtm, going to test the changes with the python-sdk and merge the PR
thanks!

// and print all incoming events

fn main() {
async_std::task::block_on(async {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔥

@theomonnom
theomonnom merged commit fa49b7e into livekit:main Mar 28, 2024
1egoman added a commit that referenced this pull request Aug 31, 2026
## Background
The `livekit-runtime` crate was [introduced in ~2024 by the folks at
zed](#310) so they could use
`livekit` in zed, which wasn't using a tokio runtime (my understanding
is, a completely custom runtime!). The general design patterns haven't
really changed since then.

A few pain points that have been encountered recently touch on
`livekit-runtime`:
1. The migration wasn't done completely, and there are quite a few tokio
runtime specific calls which were missed (or introduced later
inadvertently). One example I know of offhand is [the `tokio::fs` usage
in the `send_file` data stream
method](https://github.com/livekit/rust-sdks/blob/6078e6aed5df72c5e6613e76729f096964fbe894/livekit-data-stream/src/outgoing/manager.rs#L290).
These could be fixed piecemeal, but we'd need to extend the abstractions
further to deal with a bunch of different async operations which is
fairly burdensome.
2. Because of 1, today, the `async` and `dispatcher` features (what zed
was using specifically) don't actually build on `main` properly 😞 .
3. We should be testing to ensure that all feature combinations build in
ci, but in order to do this with the current design of `livekit-runtime`
(which isn't super well encapsulated - higher level features in the
`livekit` crate sometimes imply certain runtimes), it would be
challenging. We'd have to effectively do a build for each `platform` x
`runtime` x `ssl configuration` x any ad hoc features which is
impractical.
4. `async-std` (which the `async` feature enables) has recently been
deprecated in favor of `smol`, which we don't support today.

From what I can tell looking through zed's code, they seem to have since
migrated from the custom runtime approach they were using to a [more
typical looking tokio backed
approach](https://github.com/zed-industries/zed/blob/1e2e422c7b33b28eab0a948e442334198f3b6d27/Cargo.toml#L674).
It also looks like they [might be
using](https://github.com/zed-industries/zed/blob/1e2e422c7b33b28eab0a948e442334198f3b6d27/Cargo.toml#L979)
a [rust-sdks fork, not actually
mainline](https://github.com/zed-industries/livekit-rust-sdks). I've
done a search across all of github, and the only places that
`dispatcher` seems to be used is by stale zed forks, so I'm fairly
confident this can be dropped with little to no consequence.

## Summary

Given this context and socializing this decision with the client team,
we have decided to **drop** support for non tokio async runtimes.
`livekit-runtime` will be deprecated and all non tokio shim code will be
removed. This will address all points above (fewer features making
testing easier, no need to support `async-std`, and ci validates the
crate will always compile on tokio) and lead to a much simpler to
maintain project.

If we decide eventually that it's worth reintroducing this behavior,
then #1369 would be a good
place to start, along with taking some learnings from
https://webrtc.rs/blog/2026/01/31/async-friendly-webrtc-architecture.html.

## TODO
- [ ] Publish a final `livekit-runtime` release marking it as
deprecated.
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.

3 participants