-
Notifications
You must be signed in to change notification settings - Fork 27
Events Being Dropped on Connection #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,4 @@ lib/ | |
| web/ | ||
| *trace.json | ||
| compile_commands.json | ||
| user_stories | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,11 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "livekit/room.h" | ||
|
|
||
| #include <functional> | ||
| #include <chrono> | ||
| #include <thread> | ||
|
|
||
| #include "data_track.pb.h" | ||
| #include "ffi.pb.h" | ||
|
|
@@ -112,7 +114,7 @@ | |
| } | ||
| connection_state_ = ConnectionState::Reconnecting; | ||
| } | ||
| auto fut = FfiClient::instance().connectAsync(url, token, options); | ||
| auto fut = FfiClient::instance().connectAsync(url, token, options); // [1] | ||
| try { | ||
| auto connectCb = fut.get(); // fut will throw if it fails to connect to the room | ||
|
|
||
|
|
@@ -178,13 +180,28 @@ | |
| connection_state_ = ConnectionState::Connected; | ||
| } | ||
|
|
||
| // Install listener (Room is fully initialized) | ||
| // Proof that the issue is fixed | ||
| std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
| LK_LOG_INFO("Room::Connect: sleeping for 1 second"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the only solution? Do all livekit room connects now get a 1 second delay?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gets removed; this was just to validate the fix.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, thanks. The review was requested so was assuming this was part of the fix |
||
|
|
||
| // Install listener (Room is fully initialized) [2] | ||
| auto listenerId = FfiClient::instance().AddListener([this](const proto::FfiEvent& e) { OnEvent(e); }); | ||
| { | ||
| const std::scoped_lock<std::mutex> g(lock_); | ||
| listener_id_ = listenerId; | ||
| } | ||
|
|
||
| // Tell the Rust core it can start forwarding room events. Rust parks the | ||
| // connect task after sending the ConnectCallback, so events emitted between | ||
| // the callback and the listener registration above would otherwise be | ||
| // dropped (PushEvent has no buffering). | ||
| { | ||
| proto::FfiRequest flush_req; | ||
| auto* msg = flush_req.mutable_flush_events(); | ||
| msg->set_room_handle(static_cast<std::uint64_t>(owned_room.handle().id())); | ||
| (void)FfiClient::instance().sendRequest(flush_req); | ||
| } | ||
|
|
||
| return true; | ||
| } catch (const std::exception& e) { | ||
| // On error, set the connection_state_ to Disconnected | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What generates this path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also gets removed.