Skip to content

[macOS] Connectivity lost and never restored due to invalidated selected_entry #304

@rafael-oliveira-edge

Description

@rafael-oliveira-edge

Summary

When using libjuice on macOS, connectivity is lost shortly after establishing a connection and never recovers. This issue of losing connection shortly does not occur on Linux or Windows.

Details

The issue occurs when the connection temporarily drops and the following block in agent.c is executed:

if (nominated_pair && nominated_pair->state == ICE_CANDIDATE_PAIR_STATE_FAILED) {
    JLOG_WARN("Lost connectivity");
    agent_change_state(agent, JUICE_STATE_FAILED);
    atomic_store(&agent->selected_entry, NULL); // disallow sending
    return 0;
}

This sets the internal state to JUICE_STATE_FAILED and clears the selected_entry, which disables sending.

However, if the ICE connection is shortly re-established and the agent transition back to JUICE_STATE_COMPLETEDbut the selected_entry is never restored.

As a result:

  • The connection remains unusable for sending even though it reports a completed state.
  • No packets can be sent through the agent anymore.
  • This does not happen on Linux or Windows, only on macOS.
  • The issue occurs even if no traffic is being sent — the connection still fails quickly.

Expected Behavior

After ICE reconnects and the state returns to JUICE_STATE_COMPLETED, the agent should restore a valid selected_entry so that data can be sent again?

Platform

  • OS: macOS
  • libjuice version: 1.6.0
  • Steps to reproduce:
    1. Run a libjuice-based agent on macOS.
    2. Establish connection.
    3. Wait for a brief period (connection drops).
    4. Connection transitions to FAILED and then back to COMPLETED.
    5. Sending data fails due to selected_entry == NULL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions