Skip to content
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

ICE gathering starts too early #116

Open
JesApp opened this issue May 29, 2018 · 3 comments
Open

ICE gathering starts too early #116

JesApp opened this issue May 29, 2018 · 3 comments
Labels
bug Something isn't working

Comments

@JesApp
Copy link
Contributor

JesApp commented May 29, 2018

According to https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.9 the ICE gathering process should only start after the local description has been set. However, in my application after calling rawrtc_peer_connection_create, the rawrtc_peer_connection_local_candidate_handler is called before the negotiation_needed_handler, which is where I set the local description and send an offer to the remote peer. Since I am using trickle ICE, the rawrtc_peer_connection_local_candidate_handler just sends the ICE candidates to the remote immediately.

This is a problem, because the remote needs to receive the offer as well as create and set the answer description locally, before remote ICE candidates can be added. (The remote is Firefox 60.0.1)

@lgrahl
Copy link
Member

lgrahl commented May 29, 2018

Mh, the gathering process is being started when applying the description, so I can't quite follow you. Can you provide a call graph of relevant RAWRTC functions and event handlers? A backtrace in key places should do.

@JesApp
Copy link
Contributor Author

JesApp commented May 31, 2018

Here's the backtrace for the negotiation_needed_handler:

#0  negotiation_needed_handler (arg=0x1420a4 <client_info>) at /home/compiler/robot/src/data.c:122
#1  0x00032ed8 in rawrtc_peer_connection_create_data_channel (channelp=0x152f90, connection=0x152ee0, 
    parameters=0x153018, options=0x0, open_handler=0x167a8 <api_channel_open_handler>, 
    buffered_amount_low_handler=0x14cf4 <default_data_channel_buffered_amount_low_handler>, 
    error_handler=0x14d64 <default_data_channel_error_handler>, 
    close_handler=0x14dd4 <default_data_channel_close_handler>, 
    message_handler=0x168d8 <robot_api_message_handler>, arg=0x152f80)
    at /home/compiler/rawrtc/src/librawrtc/peer_connection.c:1510
#2  0x00015428 in initialise_client () at /home/compiler/robot/src/data.c:95
#3  0x00015278 in data_channel_setup () at /home/compiler/robot/src/data.c:62
#4  0x00017970 in main (argc=1, argv=0xbefffd64) at /home/compiler/robot/src/main.c:47

And here's one for the local_candidate_handler

#0  local_candidate_handler (candidate=0x171110, url=0x0, arg=0x1420a4 <client_info>)
    at /home/compiler/robot/src/data.c:171
#1  0x000314a0 in ice_gatherer_local_candidate_handler (ortc_candidate=0x15c930, url=0x0, arg=0x152ee0)
    at /home/compiler/rawrtc/src/librawrtc/peer_connection.c:377
#2  0x0002c55c in announce_candidate (gatherer=0x153080, re_candidate=0x170e98, url=0x0)
    at /home/compiler/rawrtc/src/librawrtc/ice_gatherer.c:272
#3  0x0002d10c in add_candidate (gatherer=0x153080, address=0xbefffa9c, protocol=RAWRTC_ICE_PROTOCOL_UDP, 
    tcp_type=ICE_TCP_ACTIVE) at /home/compiler/rawrtc/src/librawrtc/ice_gatherer.c:717
#4  0x0002d26c in interface_handler (interface=0x171c5c "wlan0", address=0xbefffa9c, arg=0x153080)
    at /home/compiler/rawrtc/src/librawrtc/ice_gatherer.c:777
#5  0x00050f84 in net_getifaddrs (ifh=0x2d18c <interface_handler>, arg=0x153080) at src/net/ifaddrs.c:56
#6  0x0004f958 in net_if_apply (ifh=0x2d18c <interface_handler>, arg=0x153080) at src/net/net.c:104
#7  0x0002d928 in rawrtc_ice_gatherer_gather (gatherer=0x153080, options=0x153050)
    at /home/compiler/rawrtc/src/librawrtc/ice_gatherer.c:1047
#8  0x000322f8 in rawrtc_peer_connection_set_local_description (connection=0x152ee0, description=0x1708a0)
    at /home/compiler/rawrtc/src/librawrtc/peer_connection.c:1004
#9  0x00015620 in negotiation_needed_handler (arg=0x1420a4 <client_info>) at /home/compiler/robot/src/data.c:131
#10 0x00032ed8 in rawrtc_peer_connection_create_data_channel (channelp=0x152f90, connection=0x152ee0, 
parameters=0x153018, options=0x0, open_handler=0x167a8 <api_channel_open_handler>, 
    buffered_amount_low_handler=0x14cf4 <default_data_channel_buffered_amount_low_handler>, 
    error_handler=0x14d64 <default_data_channel_error_handler>, 
    close_handler=0x14dd4 <default_data_channel_close_handler>, 
    message_handler=0x168d8 <robot_api_message_handler>, arg=0x152f80)
    at /home/compiler/rawrtc/src/librawrtc/peer_connection.c:1510
#11 0x00015428 in initialise_client () at /home/compiler/robot/src/data.c:95
#12 0x00015278 in data_channel_setup () at /home/compiler/robot/src/data.c:62
#13 0x00017970 in main (argc=1, argv=0xbefffd64) at /home/compiler/robot/src/main.c:47

So, if I'm reading this right set_local_description is what ends up calling local_candidate_handler which leads to local_candidate_handler finishing before negotiation_needed_handler and the ICE candidate being sent to the peer before the offer description.
Is this a bug in rawrtc or should I simply send out the offer first, before I set it locally?

@lgrahl
Copy link
Member

lgrahl commented May 31, 2018

I see. Yeah, this is a bug and I think we could queue a task to start the gathering process delayed (need to check if we can start the other transports regardless). This is not completely trivial to fix and I'm a little bit busy at the moment.

However, for now you should be able to send the offer directly after creating it. Just make sure you call set_local_description prior to calling set_remote_description. And maybe add a comment referencing this issue in the source code. 🙂

@lgrahl lgrahl added the bug Something isn't working label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants