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

[flutter_webrtc] Crash when trying to add empty IceCandidate #623

Closed
Vasques1995 opened this issue Oct 24, 2023 · 5 comments
Closed

[flutter_webrtc] Crash when trying to add empty IceCandidate #623

Vasques1995 opened this issue Oct 24, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Vasques1995
Copy link

Vasques1995 commented Oct 24, 2023

During the negotiation process, using a secure web socket for signaling, we receive an empty candidate representing the end of remote candidates, but as soon as we try to do peerConnection.addIceCandidate(RTCIceCandidate("")) the application crashes on all Tizen platforms tested.

We tried to use various combinations of old and new plugin versions, including but not limited to:

  • flutter_webrtc: 0.9.28 & flutter_webrtc_tizen: 0.1.2
  • flutter_webrtc: 0.9.23 & flutter_webrtc_tizen: 0.1.1
  • flutter_webrtc: 0.9.18 & flutter_webrtc_tizen: 0.1.0

We started testing on TizenTV as that is our main goal right now, but due to limited logging on it, we switched to TizenMobile as that platform offers a more robust logging system. Even then the logs didn't show anything substantial so I came here to try and get some help as to what may be happening.

The tizen-manifest is as follows:

> <?xml version="1.0" encoding="utf-8"?>
> <manifest package="com.example.example" version="1.0.0" api-version="6.0" xmlns="http://tizen.org/ns/packages">
>     <profile name="common"/>
>     <ui-application appid="com.example.example" exec="Runner.dll" type="dotnet" multiple="false" nodisplay="false" taskmanage="true">
>         <label>example</label>
>         <icon>ic_launcher.png</icon>
>         <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
>     </ui-application>
>     <privileges>
>         <privilege>http://tizen.org/privilege/camera</privilege>
>         <privilege>http://tizen.org/privilege/internet</privilege>
>         <privilege>http://tizen.org/privilege/recorder</privilege>
>     </privileges>
>     <feature name="http://tizen.org/feature/screen.size.all"/>
> </manifest>

Is there a better way to debug this issue than using the TizenStudio logs or the CrashDump generated and stored on the device?

@Vasques1995 Vasques1995 changed the title [web-rtc] Crash when trying to add empty IceCandidate [flutter_web-rtc] Crash when trying to add empty IceCandidate Oct 24, 2023
@Vasques1995 Vasques1995 changed the title [flutter_web-rtc] Crash when trying to add empty IceCandidate [flutter_webrtc] Crash when trying to add empty IceCandidate Oct 24, 2023
@swift-kim swift-kim added the bug Something isn't working label Oct 25, 2023
@wanchao-xu
Copy link
Contributor

wanchao-xu commented Oct 31, 2023

I commit a patch to solve crash issue of empty IceCandidate. Please refer to #625
flutter-webrtc will use libwebrtc(https://github.com/webrtc-sdk/libwebrtc), and we use version 104 of libwebrtc on tizen platform.

@xuelian-bai
Copy link

@swift-kim is there better way to debug on release image?

@swift-kim
Copy link
Member

@xuelian-bai I have no idea except for replacing dlog_print with printf in log.h (#619 (comment)).

@wanchao-xu
Copy link
Contributor

wanchao-xu commented Nov 3, 2023

I have updated libwebrtc with m114 version of webrtc sdk(https://github.com/webrtc-sdk/webrtc) on Tizen platform (#625).
I also tested the empty IceCandidate for 'addIceCandidate' api with debug libwebrtc. There is an error if candidate is empty

01-01 09:06:56.653+0900 I/ConsoleMessage(P10798, T10845): flutter: Received data: {"type":"candidate","data":{"to":"606143","from":"842756","candidate":{"sdpMLineIndex":0,"sdpMid":"0","candidate":""},"session_id":"842756-606143"}}
01-01 09:06:56.653+0900 I/TizenWebRTC(P10798, T10884): (webrtc_sdp.cc:424): Failed to parse: "". Reason: Expect line: candidate:<candidate-str>

webrtc sdk can't parse empty candidate.

I tested flutter_webrtc_demo with the empty candidate is ignored in flutter_webrtc plugin, he connection between peers is successfull.
The flutter_webrtc_demo can send empty candidate after below patch applied.

diff --git a/packages/flutter_webrtc/example/flutter_webrtc_demo/lib/src/call_sample/signaling.dart b/packages/flutter_webrtc/example/flutter_webrtc_demo/lib/src/call_sample/signaling.dart
index fc3fdb1..2227ec4 100644
--- a/packages/flutter_webrtc/example/flutter_webrtc_demo/lib/src/call_sample/signaling.dart
+++ b/packages/flutter_webrtc/example/flutter_webrtc_demo/lib/src/call_sample/signaling.dart
@@ -483,6 +483,24 @@ class Signaling {
               }));
     };

+    pc.onIceGatheringState = (state) async {
+      print("onIceGatheringState: " + state.toString());
+      if (state == RTCIceGatheringState.RTCIceGatheringStateComplete) {
+          await Future.delayed(
+                const Duration(seconds: 1),
+                () => _send('candidate', {
+                  'to': peerId,
+                  'from': _selfId,
+                  'candidate': {
+                    'sdpMLineIndex': 0,
+                    'sdpMid': '0',
+                    'candidate': '',
+                  },
+                  'session_id': sessionId,
+              }));
+      }
+    };
+
     pc.onIceConnectionState = (state) {};

The addIceCandidate method provides a remote candidate to the ICE Agent. This method can also be used to indicate the end of remote candidates when called with an empty string for the candidate member.

It maybe have no effect on peer connection even empty IceCandidate ignored.
Please refer to sample

If there is peer connection failed because of empty candidate, please share the test app to me.

@xiaowei-guan
Copy link
Contributor

@Vasques1995 We have fix IceCandidate issue, please apply latest flutter_webrtc_tizen version:

dependencies:
 flutter_webrtc: ^0.9.46
 flutter_webrtc_tizen: ^0.1.3

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

5 participants