Skip to content

Race condition: Futures can wait on an async_id that's already been delivered to PushEvent #15

@artgillespie

Description

@artgillespie

Thanks for all the recent updates @xianshijing-lk!

In my application, I'm calling room.localParticipant()->publishData(...) at 10Hz with a tiny (34 byte) payload in a loop from the main thread of a ROS node.

The amount of time varies, but eventually the call will block indefinitely.

I traced this down to this call fut.get(): https://github.com/livekit/client-sdk-cpp/blob/main/src/local_participant.cpp#L68

Further debugging identified the root cause: the FfiEvent with the corresponding async_id is delivered in the short window between calling sendRequest and registering the async handler.

I've patched LocalParticipant::publishData locally so that the fut.get() is instead a fut.wait_for(...) to get unblocked (let me know if you'd like a PR!), but it might be worth having a discussion about how we might update the core ffi async handling to avoid this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions