alongubkin / phonertc

WebRTC for Cordova apps - No longer active
http://phonertc.io
Apache License 2.0
866 stars 305 forks source link

IceGatheringChange state COMPLETE before all candidates #211

Open Niteesh opened 8 years ago

Niteesh commented 8 years ago

Looks like COMPLETE event is fired before all candidates are gathered and we receive the candidates event after this events in JS.

public void onIceGatheringChange(final IceGatheringState arg0) { try { JSONObject json = new JSONObject(); json.put("type", "IceGatheringChange"); json.put("state", arg0.name()); sendMessage(json); } catch (JSONException e) { e.printStackTrace(); } }

I think this should run on UI thread as below.

public void onIceGatheringChange(final IceGatheringState arg0) { _plugin.getActivity().runOnUiThread(new Runnable() { public void run() { try { JSONObject json = new JSONObject(); json.put("type", "IceGatheringChange"); json.put("state", arg0.name()); sendMessage(json); } catch (JSONException e) { e.printStackTrace(); } } });

}

HOW TO TEST: In scenario when both parties are behind symmetric NAT, sometimes video does not come because relay candidates are not shared. As they are the last ones to appear i could also see the firing of COMPLETE event before these candidates.

I am not 100% sure if this would solve the problem but there should be a way to order these events.