client-sdk-flutter icon indicating copy to clipboard operation
client-sdk-flutter copied to clipboard

Example app connect when running android version but windows version won't connect

Open hesam-khorshidi opened this issue 2 years ago • 11 comments

I tried to run connect to my livekit server using the example app in github and the app I wrote myself. In both cases I can connect to my room when running app in android emulator but when I run the app in windows mode I cannot connect to the same room in the same server.

Here's the full log :

flutter: Engine ConnectionState disconnected -> connecting
flutter: [EngineEvent] Engine#1012341134 EngineConnectionStateUpdatedEvent(newState: connecting, didReconnect: false, disconnectReason: null)
flutter: SignalClient ConnectionState disconnected -> connecting
flutter: [SignalClient#516488551] cleanUp()
flutter: [SignalEvent] SignalConnectionStateUpdatedEvent(newState: connecting, didReconnect: false, disconnectReason: null)
flutter: [WebSocketIO] Connected
flutter: SignalClient ConnectionState connecting -> connected
flutter: [SignalEvent] SignalConnectionStateUpdatedEvent(newState: connected, didReconnect: false, disconnectReason: null)
flutter: ping config timeout: 20, interval: 10 
flutter: [SignalEvent] Instance of 'SignalJoinResponseEvent'
flutter: onConnected subscriberPrimary: true, serverVersion: 1.4.5, iceServers: [urls: stun:stun.l.google.com:19302
urls: stun:stun1.l.google.com:19302
], forceRelay: Instance of 'SignalJoinResponseEvent'.response.clientConfiguration.forceRelay
flutter: [Engine] Received JoinResponse, serverVersion: 1.4.5
flutter: Room Connect completed
flutter: [PCTransport] creating {sdpSemantics: unified-plan, iceServers: [{urls: [stun:stun.l.google.com:19302, stun:stun1.l.google.com:19302]}]}
flutter: [ParticipantEvent] ParticipantMetadataUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin)), will notifyListeners()
flutter: [RoomEvent] ParticipantMetadataUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin)), will notifyListeners()
flutter: [ParticipantEvent] ParticipantPermissionsUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin), permissions: Instance of 'ParticipantPermissions'), will notifyListeners()
flutter: [RoomEvent] ParticipantPermissionsUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin), permissions: Instance of 'ParticipantPermissions'), will notifyListeners()
flutter: [SignalEvent] Instance of 'SignalParticipantUpdateEvent'
flutter: [ParticipantEvent] ParticipantPermissionsUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin), permissions: Instance of 'ParticipantPermissions'), will notifyListeners()
flutter: [RoomEvent] ParticipantPermissionsUpdatedEvent(participant: LocalParticipant(sid: PA_Re9VE4viM9MJ, identity: admin), permissions: Instance of 'ParticipantPermissions'), will notifyListeners()
flutter: [PCTransport] creating {sdpSemantics: unified-plan, iceServers: [{urls: [stun:stun.l.google.com:19302, stun:stun1.l.google.com:19302]}]}
flutter: [SignalEvent] Instance of 'SignalTokenUpdatedEvent'
flutter: [SignalEvent] Instance of 'SignalOfferEvent'
[ERROR:flutter/shell/common/shell.cc(1004)] The 'FlutterWebRTC/peerConnectionEvent8B6403F8-A1E1-43C2-9FD6-10CA36E9B537' 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.
flutter: [SignalEvent] Instance of 'SignalTrickleEvent'
flutter: [SignalEvent] Instance of 'SignalTrickleEvent'
flutter: EventsListener<SignalEvent>#815885597 event was cancelled by func
flutter: Waiting for engine to connect...
flutter: Server refreshed the token
flutter: [SignalEvent] Instance of 'SignalTrickleEvent'
flutter: [Engine#1012341134] Received server offer(type: offer, RTCSignalingState.RTCSignalingStateStable)
[ERROR:flutter/shell/common/shell.cc(1004)] The 'FlutterWebRTC/peerConnectionEvent899BCA61-3EB3-462D-9C33-C1620F4587C8' 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.
flutter: [SignalEvent] Instance of 'SignalTrickleEvent'
flutter: [SignalEvent] Instance of 'SignalTrickleEvent'
flutter: Created answer
flutter: got ICE candidate from peer
flutter: subscriber onIceCandidate
flutter: subscriber onIceCandidate
flutter: pc.getRemoteDescription Instance of 'RTCSessionDescription'
flutter: got ICE candidate from peer
flutter: subscriber iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateChecking
flutter: pc.getRemoteDescription Instance of 'RTCSessionDescription'
flutter: got ICE candidate from peer
flutter: pc.getRemoteDescription Instance of 'RTCSessionDescription'
flutter: got ICE candidate from peer
flutter: pc.getRemoteDescription Instance of 'RTCSessionDescription'
flutter: got ICE candidate from peer
flutter: pc.getRemoteDescription Instance of 'RTCSessionDescription'
flutter: subscriber onIceCandidate
flutter: [SignalEvent] Instance of 'SignalRoomUpdateEvent'
flutter: EventsEmitter<EngineEvent>#777998414 event was cancelled by func
flutter: Connect Error LiveKit Exception: [ConnectException] Timed out waiting for EnginePeerStateUpdatedEvent
flutter: Engine ConnectionState connecting -> disconnected
flutter: Could not connect LiveKit Exception: [ConnectException] Timed out waiting for EnginePeerStateUpdatedEvent
flutter: [EngineEvent] Engine#1012341134 EngineConnectionStateUpdatedEvent(newState: disconnected, didReconnect: false, disconnectReason: null)
flutter: [Room#301983608] cleanUp()
flutter: [Engine#1012341134] cleanUp()
flutter: [SignalClient#516488551] cleanUp()
flutter: [RoomEvent] RoomDisconnectedEvent(null), will notifyListeners()
flutter: SignalClient onSocketDispose ConnectionState.connected
flutter: SignalClient did disconnect ConnectionState.connected
flutter: SignalClient ConnectionState connected -> disconnected
flutter: [SignalEvent] SignalConnectionStateUpdatedEvent(newState: disconnected, didReconnect: false, disconnectReason: null)
flutter: onDisconnected state:ConnectionState.disconnected reason:signal
flutter: [Engine#1012341134] Already disconnected... ClientDisconnectReason.signal

hesam-khorshidi avatar Sep 09 '23 11:09 hesam-khorshidi

same problem

image

mostcute avatar Sep 26 '23 08:09 mostcute

i also see this err

The 'FlutterWebRTC/peerConnectionEventAAE6C637-9A54-4265-A2D5-E7599878E977' 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.

mostcute avatar Sep 27 '23 06:09 mostcute

found the problem ,need to update the flutter-webrtc version, maybe need to wait flutter-webrtc^0.9.45 published, 0.9.44 not contains the fix https://github.com/flutter-webrtc/flutter-webrtc/pull/1458

mostcute avatar Sep 27 '23 06:09 mostcute

The flutter plugin for windows currently does not support thread safety and send events to the main thread, but if you use the flutter stable channel for windows it should work correctly.

https://github.com/flutter/flutter/issues/135502 https://github.com/flutter/flutter/issues/79213

cloudwebrtc avatar Sep 27 '23 08:09 cloudwebrtc

I found that this fault message only appears in the flutter master channel. I think we need to wait until the next major flutter version upgrade to fix this issue. There is a high probability that Flutter Windows will provide relevant APIs to send tasks to the flutter main thread.

cloudwebrtc avatar Sep 27 '23 08:09 cloudwebrtc

Flutter 3.13.2 • channel stable • Framework • revision ff5b5b5fa6 (5 weeks ago) • 2023-08-24 08:12:28 -0500 Engine • revision b20183e040 Tools • Dart 3.1.0 • DevTools 2.25.0

mostcute avatar Sep 27 '23 08:09 mostcute

can you try downgrading to 3.10.4? this version works for me, As you mentioned, I can reproduce this issue by upgrading to 3.13.x, but we still need to wait for the flutter team to fix the issue.

cloudwebrtc avatar Sep 27 '23 08:09 cloudwebrtc

there is no need to downgrade,. 3.10.x is the version i used last mounth, there is no problem i have to upgrade because i use some pkg need 3.13

i can wait to fix the issue on mac and windows util the flutter tem release new version, maybe https://github.com/flutter-webrtc/flutter-webrtc/pull/1458 fix on macos in a tmp way?

mostcute avatar Sep 27 '23 08:09 mostcute

maybe https://github.com/flutter-webrtc/flutter-webrtc/pull/1458 fix on macos in a tmp way?

Yes, I've fixed the issue on macOS/iOS.

cloudwebrtc avatar Sep 27 '23 08:09 cloudwebrtc

Hi @cloudwebrtc We are currently having same issue running on Linux and Windows:

[ERROR:flutter/shell/common/shell.cc(1038)] The 'FlutterWebRTC/dataChannelEventE3A06EE6-FE72-437F-83C3-49FE7EA5F5061286C5B1-ECF9-4F1D-9EB5-A21E18A35E16' 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.

Is there any solution? Can we do something to fix it? We test it with different livekit_client and flutter versions. Only with v3.10.4 (as you say in other comment) it works but we need to upgrade other packages.

lautaroalvarez avatar Mar 12 '24 13:03 lautaroalvarez

Linux platform same error

[ERROR:flutter/shell/common/shell.cc(1055)] The 'FlutterWebRTC/Texture93860604184960' 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.
[ERROR:flutter/shell/common/shell.cc(1055)] The 'FlutterWebRTC/Texture93860594641680' 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.
Lost connection to device.
the Dart compiler exited unexpectedly.

Nightwelf avatar Jun 21 '24 11:06 Nightwelf