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

[Windows] app crashes as soon as voice connection is established with code 200 #529

Open
Osama-Al-Fawaz opened this issue Mar 5, 2025 · 10 comments
Labels
bug Something isn't working

Comments

@Osama-Al-Fawaz
Copy link

Describe the bug
when establishing an sip connection i get this warning: [ERROR:flutter/shell/common/shell.cc(1065)] The 'FlutterWebRTC/peerConnectionEvent53367CBD-CE90-48C7-999C-20EB1E41FBD2' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel. See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information. but the app only crashes after the connection has been established

SIP/2.0 200 OK
...
flutter: [2025-03-04 06:05:53.69] Level.debug rtc_session.dart:981 ::: mute()
flutter: [2025-03-04 06:05:53.71] Level.debug rtc_session.dart:3306 ::: session onmute
flutter: [2025-03-04 06:05:53.71] Level.debug rtc_session.dart:3308 ::: emit "muted"
...
flutter: [2025-03-04 06:05:53.72] Level.debug sip_ua_helper.dart:322 ::: call muted
Lost connection to device.

Exited.

I could not find a previous issue here, but I have seen a similar issue on liveKit issue#586. I created this issue since I couldn't really apply a workaround similar to this as it seems sip_ua is tightly coupled with flutter_webrtc, and a solution couldn't come to mind. Any help would be appreciated (even alternatives for Windows) as I am currently targeting Windows after successfully deploying on MacOS.

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to join any call
  2. Wait for sip to connect
  3. The app crashes immediately

Expected behavior
The app does not crash, and I can proceed to use audio functionalities.

System Infomation()
Flutter SDK Version: 3.24.3
Target OS and Version: Windows 10 22H2 and Windows 11
Host OS and Version: Windows 10 22H2

@cloudwebrtc
Copy link
Member

hi, Can you try to confirm that flutter clean runs correctly, and then run flutter pub get. I tried testing in dart-sip-ua, and the error Platform channel messages must be sent on the platform thread has disappeared

@Osama-Al-Fawaz
Copy link
Author

Platform channel

yes actually the message did indeed disappear after the fix you implemented but the crashing is not solved. the only change from the implementation on other platforms that I made is in the settings:

...
settings.dtmfMode = Platform.isWindows ? DtmfMode.INFO : DtmfMode.RFC2833;
...

I found this necessary since if I don't use DtmfMode.INFO the connection will be stuck after CallStateEnum.STREAM (no voice connections or control and technically in echo test) with this error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(sendDtmf, sendDtmf() rtpSender is null, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
message_codecs.dart:648
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
platform_channel.dart:334
<asynchronous suspension>
#2      RTCDTMFSenderNative.insertDTMF (package:flutter_webrtc/src/native/rtc_dtmf_sender_impl.dart:14:5)
rtc_dtmf_sender_impl.dart:14
<asynchronous suspension>

here is one of the issues I referenced for this fix: #408 I remember seeing another issue as well but I couldn't find it

@cloudwebrtc
Copy link
Member

Thanks for the details, I think this might be another bug.

@Osama-Al-Fawaz
Copy link
Author

here are some additional logs before crashing while using DTMF.info and after CallStateEnum.STREAM:

flutter: [2025-03-23 16:15:02.542] Level.debug rtc_session.dart:864 ::: sendDTMF() | tones: 1
flutter: [2025-03-23 16:15:02.545] Level.debug rtc_session.dart:1459 ::: newDTMF()
flutter: [2025-03-23 16:15:02.545] Level.debug rtc_session.dart:1264 ::: sendRequest()
flutter: [2025-03-23 16:15:02.548] Level.debug socket_transport.dart:128 ::: Socket Transport send()
flutter: [2025-03-23 16:15:02.548] Level.debug sip_message.dart:276 ::: Outgoing Message: SipMethod.INFO body: Signal=1
Duration=70
flutter: [2025-03-23 16:15:02.549] Level.debug web_socket.dart:136 ::: send()
flutter: [2025-03-23 16:15:02.549] Level.debug websocket_dart_impl.dart:54 ::: send: 
...
Duration=70
flutter: [2025-03-23 16:15:02.595] Level.debug web_socket.dart:176 ::: Received WebSocket message
flutter: [2025-03-23 16:15:02.596] Level.debug socket_transport.dart:278 ::: received text message:
...

I have removed some confirmation logs as it may be sensitive

@Osama-Al-Fawaz
Copy link
Author

Thanks for the details, I think this might be another bug.

i see... that is unfortunate. is there an issue on this or will we treat this issue as the one for that bug. do you have any idea what the root cause may be?
also many thanks for your cooperation and fast responses

@cloudwebrtc
Copy link
Member

cloudwebrtc commented Mar 23, 2025

bug fixed for RFC2833. #534

@Osama-Al-Fawaz
Copy link
Author

Osama-Al-Fawaz commented Mar 23, 2025

bug fixed for RFC2833. #534

i think this fixes another issue but not the crashing issue. now my app crashes with either DTMF.info or DtmfMode.RFC2833 ;)

but can confirm the error no longer appears. only a crash...

@cloudwebrtc
Copy link
Member

you can try to open build\windows\x64\dart_sip_ua_example.sln in vs2022, run your app in debug mode, then you can track the crash information, which can help you identify the cause.

@Osama-Al-Fawaz
Copy link
Author

you can try to open build\windows\x64\dart_sip_ua_example.sln in vs2022, run your app in debug mode, then you can track the crash information, which can help you identify the cause.

SOLVED! what great advice. thank u so much. after some digging and learning to navigate sln and visual studio I found the cause.
it is this helper method Helper.setSpeakerphoneOnButPreferBluetooth(); as soon as i connect successfully i call it and on windows it causes the crash (i suspect on linux too).
i will try to include useful info from VS debugging but if something is missing feel free to contact me:
Unhandled exception at <memory_address>(ucrtbased.dll) in <my_app_name>.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.

simple callstack:

 	ucrtbased.dll!00007ff9df34afec()	Unknown
 	flutter_webrtc_plugin.dll!std::bad_variant_access::_Doraise Line 405	C++
 	flutter_webrtc_plugin.dll!stdext::exception::_Raise Line 113	C++
 	flutter_webrtc_plugin.dll!std::_Throw_bad_variant_access Line 410	C++
 	flutter_webrtc_plugin.dll!std::get<...> Line 1220	C++
 	flutter_webrtc_plugin.dll!std::get<...> Line 1259	C++
 	flutter_webrtc_plugin.dll!GetValue<...> Line 44	C++
 	flutter_webrtc_plugin.dll!flutter_webrtc_plugin::FlutterFrameCryptor::HandleFrameCryptorMethodCall Line 58	C++
 	flutter_webrtc_plugin.dll!flutter_webrtc_plugin::FlutterWebRTC::HandleMethodCall Line 1246	C++
 	flutter_webrtc_plugin.dll!flutter_webrtc_plugin::FlutterWebRTCPluginImpl::HandleMethodCall Line 57	C++
 	flutter_webrtc_plugin.dll!<lambda_c6da590aa8ac81730b72e43f7a896b8b>::operator()<...> Line 27	C++
 	[External Code]	
 	flutter_webrtc_plugin.dll!flutter::MethodChannel<...>::SetMethodCallHandler::__l2::<lambda> Line 121	C++
 	[External Code]	
>	flutter_webrtc_plugin.dll!flutter::`anonymous namespace'::ForwardToHandler Line 76	C++
 	[External Code]	
 	<my_app_name>.exe!wWinMain Line 39	C++
 	[External Code]	

hope this helps. thank you for your efforts ❤

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