Skip to content

fix: Try to fix the non-platform thread call error. #1795

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

Merged
merged 4 commits into from
Mar 24, 2025

Conversation

cloudwebrtc
Copy link
Member

No description provided.

@Osama-Al-Fawaz
Copy link

Thank you for the fix but I still get the crash on windows 10. note that I am not using livekit instead we are using flutter_webrtc and sip_ua and my issue is with sip_ua.
maybe I am missing something but I tried the fix by overriding the dependency like so:

dependencies:
flutter_webrtc: ^0.12.11
sip_ua: ^1.0.1

dependency_overrides:
  flutter_webrtc:
    git:
      url: https://github.com/flutter-webrtc/flutter-webrtc.git
      ref: fix/cross-thread-event-post-for-win

this is the output upon resolving dependencies:

Resolving dependencies... 
Downloading packages...
...
! flutter_webrtc 0.12.12+hotfix.1 from git https://github.com/flutter-webrtc/flutter-webrtc.git at 2ba633 (overridden)
...
Got dependencies!

@Osama-Al-Fawaz
Copy link

Osama-Al-Fawaz commented Mar 23, 2025

@cloudwebrtc cloudwebrtc merged commit 1c2ff6f into main Mar 24, 2025
15 of 16 checks passed
@cloudwebrtc cloudwebrtc deleted the fix/cross-thread-event-post-for-win branch March 24, 2025 03:38
@1056824847
Copy link

hi @cloudwebrtc , On Linux, I upgraded the flutter_webrtc library to 0.13.0, but it still crashed

dependencies:
flutter_web_plugins:
sdk: flutter
flutter:
sdk: flutter
async: ^2.9.0
collection: ^1.19.1
connectivity_plus: ^6.0.2
fixnum: ^1.0.1
meta: ^1.8.0
http: ^1.3.0
logging: ^1.1.0
uuid: ^4.5.1
synchronized: ^3.0.0+3
protobuf: ^3.0.0
flutter_webrtc: 0.13.0
device_info_plus: ^11.3.0
dart_webrtc: 1.5.3
sdp_transform: ^0.3.2
web: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
lints: ^4.0.0
mockito: ^5.3.2
import_sorter: ^4.6.0
yaml: ^3.1.2
dependency_overrides:
flutter_webrtc: 0.13.0

[  +11 ms] -- Install configuration: "Debug"
[  +31 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/example
[   +6 ms] -- Set runtime path of "/home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/example" to "$ORIGIN/lib"
[   +4 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/icudtl.dat
[   +1 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/lib/libflutter_linux_gtk.so
[  +26 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/lib/libflutter_webrtc_plugin.so
[  +12 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/lib/libwebrtc.so
[  +17 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/images
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/images/logo-dark.svg
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/NativeAssetsManifest.json
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/FontManifest.json
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/fonts
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/fonts/MaterialIcons-Regular.otf
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/AssetManifest.bin
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/version.json
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/NOTICES.Z
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/kernel_blob.bin
[  +71 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/shaders
[   +1 ms] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/shaders/ink_sparkle.frag
[        ] -- Installing: /home/wzh/桌面/client-sdk-flutter/example/build/linux/arm64/debug/bundle/data/flutter_assets/AssetManifest.json
[  +36 ms] Building Linux application... (completed in 4.5s)
[   +4 ms] ✓ Built build/linux/arm64/debug/bundle/example
[  +87 ms] (example:451529): dbind-WARNING **: 17:53:40.043: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
[ +169 ms] (example:451529): Atk-CRITICAL **: 17:53:40.215: atk_socket_embed: assertion 'plug_id != NULL' failed
[ +119 ms] VM Service URL on device: http://127.0.0.1:39499/Bt9JpLZSolo=/
[  +11 ms] Caching compiled dill
[ +469 ms] Connecting to service protocol: http://127.0.0.1:39499/Bt9JpLZSolo=/
[ +237 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:39499/Bt9JpLZSolo=/.
[ +687 ms] Successfully connected to service protocol: http://127.0.0.1:39499/Bt9JpLZSolo=/
[  +16 ms] DevFS: Creating new filesystem on the device (null)
[  +39 ms] DevFS: Created new filesystem on the device (file:///tmp/examplePUIXMM/example/)
[   +2 ms] Updating assets
[ +231 ms] Syncing files to device Linux...
[   +2 ms] Compiling dart to kernel with 0 updated files
[        ] Processing bundle.
[   +1 ms] <- recompile package:livekit_example/main.dart e16dd956-5247-47a8-a3c2-634f4bbdf9e1
[        ] <- e16dd956-5247-47a8-a3c2-634f4bbdf9e1
[   +1 ms] Bundle processing done.
[ +164 ms] Updating files.
[        ] Pending asset builds completed. Writing dirty entries.
[        ] DevFS: Sync finished
[   +1 ms] Syncing files to device Linux... (completed in 170ms)
[   +1 ms] Synced 0.0MB.
[   +1 ms] <- accept
[  +74 ms] Connected to _flutterView/0x2dd112d0.
[   +2 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] A Dart VM Service on Linux is available at: http://127.0.0.1:39107/uALv8YcWdWA=/
[ +164 ms] The Flutter DevTools debugger and profiler on Linux is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:39107/uALv8YcWdWA=/
[+3725 ms] flutter: Connecting with url: ws://dtqmeeting.com:7880, token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDcyMDg5MDgsImlzcyI6ImFwaUtleTFkZmFzZnNhZmFzZGZhZHNmYWZkYWZkYXNmYWZhZmFmIiwibmFtZSI6InVzZXIyIiwibmJmIjoxNzQyODAyNTA4LCJzdWIiOiJ1c2VyMiIsInZpZGVvIjp7InJvb20iOiJteS1maXJzdC1yb29tIiwicm9vbUpva
W4iOnRydWV9fQ.AYBZw1HHagWJzZp2_R5D2GWb-TZUhyL7lnpum3KAWTI...
[ +468 ms] flutter: 17:53:46: LocalAudioTrack#920701340.start()
[   +4 ms] flutter: 17:53:46: AudioTrack.onStarted()
[+3947 ms] flutter: 17:53:50: prepareConnection to ws://dtqmeeting.[+4381 ms] flutter: 17:53:54: Connectivity changed, [ConnectivityResult.ethernet] => [ConnectivityResult.ethernet]
[   +1 ms] flutter: 17:53:54: [SignalEvent] Instance of 'SignalConnectivityChangedEvent'
[  +79 ms] flutter: 17:53:55: SignalClient connecting with url:
ws://dtqmeeting.com:7880/rtc?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDcyMDg5MDgsImlzcyI6ImFwaUtleTFkZmFzZnNhZmFzZGZhZHNmYWZkYWZkYXNmYWZhZmFmIiwibmFtZSI6InVzZXIyIiwibmJmIjoxNzQyODAyNTA4LCJzdWIiOiJ1c2VyMiIsInZpZGVvIjp
7InJvb20iOiJteS1maXJzdC1yb29tIiwicm9vbUpvaW4iOnRydWV9fQ.AYBZw1HHagWJzZp2_R5D2GWb-TZUhyL7lnpum3KAWTI&auto_subscribe=1&adaptive_stream=1&protocol=12&sdk=flutter&version=2.4.1&network=wired&os=linux&os_version=v10&device_model=7fa4e67c726141
d084ce83c3b8117922
[   +4 ms] flutter: 17:53:55: [SignalClient#654710700] cleanUp()
[        ] flutter: 17:53:55: [SignalEvent] Instance of 'SignalConnectingEvent'
[        ] flutter: 17:53:55: [WebSocketIO] Connecting(uri:
ws://dtqmeeting.com:7880/rtc?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDcyMDg5MDgsImlzcyI6ImFwaUtleTFkZmFzZnNhZmFzZGZhZHNmYWZkYWZkYXNmYWZhZmFmIiwibmFtZSI6InVzZXIyIiwibmJmIjoxNzQyODAyNTA4LCJzdWIiOiJ1c2VyMiIsInZpZGVvIjp
7InJvb20iOiJteS1maXJzdC1yb29tIiwicm9vbUpvaW4iOnRydWV9fQ.AYBZw1HHagWJzZp2_R5D2GWb-TZUhyL7lnpum3KAWTI&auto_subscribe=1&adaptive_stream=1&protocol=12&sdk=flutter&version=2.4.1&network=wired&os=linux&os_version=v10&device_model=7fa4e67c726141
d084ce83c3b8117922)...
[   +8 ms] flutter: 17:53:55: Signal connecting
[   +1 ms] flutter: 17:53:55: [EngineEvent] Engine#688146836 Instance of 'EngineConnectingEvent'
[+4151 ms] flutter: 17:53:59: [WebSocketIO] Connected
[  +40 ms] flutter: 17:53:59: ping config timeout: 15, interval: 5 
[   +8 ms] flutter: 17:53:59: [SignalEvent] Instance of 'SignalConnectedEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalJoinResponseEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalTokenUpdatedEvent'
[        ] flutter: 17:53:59: Signal connected
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalOfferEvent'
[   +1 ms] flutter: 17:53:59: [EngineEvent] Engine#688146836 Instance of 'EngineConnectedEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalTrickleEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalTrickleEvent'
[   +5 ms] flutter: 17:53:59: onConnected subscriberPrimary: true, serverVersion: 1.7.2, iceServers: [urls: stun:global.stun.twilio.com:3478
[        ] urls: stun:stun.l.google.com:19302
[        ] urls: stun:stun1.l.google.com:19302
[        ] ], forceRelay: Instance of 'SignalJoinResponseEvent'.response.clientConfiguration.forceRelay
[   +6 ms] flutter: 17:53:59: [PCTransport] creating {sdpSemantics: unified-plan, iceServers: [{urls: [stun:global.stun.twilio.com:3478, stun:stun.l.google.com:19302, stun:stun1.l.google.com:19302]}]}
[   +5 ms] flutter: 17:53:59: [PCTransport] creating {sdpSemantics: unified-plan, iceServers: [{urls: [stun:global.stun.twilio.com:3478, stun:stun.l.google.com:19302, stun:stun1.l.google.com:19302]}]}
[  +97 ms] [ERROR:flutter/shell/common/shell.cc(1057)] The 'FlutterWebRTC/peerConnectionEventBA8BED86-6E3C-41B6-9C84-8F3FBE9EE553' 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.
[   +2 ms] See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
[  +36 ms] flutter: 17:53:59: [EngineEvent] Engine#688146836 Instance of 'EngineJoinResponseEvent'
[   +4 ms] flutter: 17:53:59: [Engine] Received JoinResponse, serverVersion: 1.7.2
[  +43 ms] flutter: 17:53:59: Room Connect completed
[   +3 ms] flutter: 17:53:59: EventsEmitter<EngineEvent>#362770705 event was cancelled by func
[        ] flutter: 17:53:59: Waiting for engine to connect...
[        ] flutter: 17:53:59: Server refreshed the token
[   +9 ms] flutter: 17:53:59: [SignalEvent] Instance of 'SignalLocalTrackPublishedEvent'
[   +6 ms] flutter: 17:53:59: [Engine#688146836] Received server offer(type: offer, RTCSignalingState.RTCSignalingStateStable)
[  +34 ms] [ERROR:flutter/shell/common/shell.cc(1057)] The 'FlutterWebRTC/peerConnectionEvent7AC8369E-6000-411B-9C3E-7505EF59B46C' 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.
[   +2 ms] See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
[  +43 ms] flutter: 17:53:59: Created answer
[  +50 ms] flutter: 17:53:59: got ICE candidate from peer (target: SUBSCRIBER)
[   +1 ms] flutter: 17:53:59: subscriber onIceCandidate
[   +1 ms] flutter: 17:53:59: subscriber onIceCandidate
[        ] flutter: 17:53:59: starting to negotiate
[  +88 ms] flutter: 17:53:59: setting munged local
[   +1 ms] flutter: 17:53:59: got ICE candidate from peer (target: SUBSCRIBER)
[   +2 ms] flutter: 17:53:59: subscriber connectionState: RTCPeerConnectionState.RTCPeerConnectionStateConnecting
[        ] flutter: 17:53:59: [EngineEvent] Engine#688146836 EngineSubscriberPeerStateUpdatedEvent(state: RTCPeerConnectionState.RTCPeerConnectionStateConnecting, isPrimary: true)
[        ] flutter: 17:53:59: subscriber iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateChecking
[  +11 ms] flutter: 17:53:59: publisher onOffer
[   +4 ms] flutter: 17:53:59: publisher onIceCandidate
[   +1 ms] flutter: 17:53:59: publisher onIceCandidate
[        ] flutter: 17:53:59: publisher onIceCandidate
[        ] flutter: 17:53:59: publisher onIceCandidate
[   +8 ms] flutter: 17:53:59: [SignalEvent] Instance of 'SignalAnswerEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalTrickleEvent'
[        ] flutter: 17:53:59: [SignalEvent] Instance of 'SignalTrickleEvent'
[  +13 ms] flutter: 17:53:59: EventsListener<SignalEvent>#12842173 event was cancelled by func
[   +3 ms] flutter: 17:53:59: publishAudioTrack engine.addTrack response: sid: TR_AMsr3ssbQcw8Uh
[   +5 ms] name: custom_audio_track_name
[   +1 ms] source: MICROPHONE
[        ] disableRed: true
[        ] stream: camera
[   +1 ms] flutter: 17:53:59: LocalAudioTrack#920701340.publish()
[        ] flutter: 17:53:59: onAudioTrackCountDidChange: local: 1, remote: 0
[        ] flutter: 17:53:59: didUpdateSate: AudioTrackState.localOnly
[        ] flutter: 17:53:59: received answer (type: answer)
[  +27 ms] flutter: 17:53:59: publisher iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateChecking
[   +1 ms] flutter: 17:53:59: got ICE candidate from peer (target: PUBLISHER)
[  +90 ms] flutter: 17:53:59: publisher onIceCandidate
[  +14 ms] flutter: 17:53:59: publisher connectionState: RTCPeerConnectionState.RTCPeerConnectionStateConnecting
[        ] flutter: 17:53:59: [EngineEvent] Engine#688146836 EnginePublisherPeerStateUpdatedEvent(state: RTCPeerConnectionState.RTCPeerConnectionStateConnecting, isPrimary: false)
[        ] flutter: 17:53:59: got ICE candidate from peer (target: PUBLISHER)
[  +19 ms] flutter: 17:53:59: publisher connectionState: RTCPeerConnectionState.RTCPeerConnectionStateConnected
[        ] flutter: 17:53:59: [EngineEvent] Engine#688146836 EnginePublisherPeerStateUpdatedEvent(state: RTCPeerConnectionState.RTCPeerConnectionStateConnected, isPrimary: false)
[   +1 ms] flutter: 17:53:59: publisher iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateConnected
[   +2 ms] flutter: 17:53:59: publisher iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateCompleted
[  +10 ms] [ERROR:flutter/shell/common/shell.cc(1057)] The 'FlutterWebRTC/dataChannelEventBA8BED86-6E3C-41B6-9C84-8F3FBE9EE553FAFE6755-D454-49FB-AFC9-BCF899FC9AF9' 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.
[   +2 ms] See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.
[        ] [ERROR:flutter/shell/common/shell.cc(1057)] The 'FlutterWebRTC/dataChannelEventBA8BED86-6E3C-41B6-9C84-8F3FBE9EE5538B50F5F0-8306-4880-A68A-90F110AB8F48' 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: 17:53:59: [EngineEvent] Engine#688146836 Instance of 'PublisherDataChannelStateUpdatedEvent'
[        ] flutter: 17:53:59: [EngineEvent] Engine#688146836 Instance of 'PublisherDataChannelStateUpdatedEvent'
[  +15 ms] flutter: 17:53:59: Connected address: 106.52.238.158:5061
[ +740 ms] flutter: 17:54:00: subscriber connectionState: RTCPeerConnectionState.RTCPeerConnectionStateConnected
[        ] flutter: 17:54:00: [EngineEvent] Engine#688146836 EngineSubscriberPeerStateUpdatedEvent(state: RTCPeerConnectionState.RTCPeerConnectionStateConnected, isPrimary: true)
[        ] flutter: 17:54:00: EventsEmitter<EngineEvent>#362770705 event was cancelled by func
[        ] flutter: 17:54:00: [EngineEvent] Engine#688146836 Instance of 'EngineConnectedEvent'
[        ] flutter: 17:54:00: subscriber iceConnectionState: RTCIceConnectionState.RTCIceConnectionStateConnected
[   +9 ms] flutter: 17:54:00: Server opened DC label: _reliable
[   +8 ms] flutter: 17:54:00: Server opened DC label: _lossy
[ +205 ms] flutter: 17:54:00: Connected address: 106.52.238.158:5061
[+1078 ms] flutter: 17:54:02: [SignalEvent] Instance of 'SignalParticipantUpdateEvent'
[   +3 ms] flutter: 17:54:02: [SignalEvent] Instance of 'SignalParticipantUpdateEvent'
[+2167 ms] flutter: 17:54:04: [SignalEvent] Instance of 'SignalConnectionQualityUpdateEvent'
[   +5 ms] flutter: 17:54:04: [SignalEvent] Instance of 'SignalRoomUpdateEvent'
[   +4 ms] flutter: Room metadata changed: 
[+2844 ms] Service protocol connection closed.
[   +1 ms] Lost connection to device.
[   +2 ms] DevFS: Deleting filesystem on the device (file:///tmp/examplePUIXMM/example/)
[   +3 ms] DevFS: Deleted filesystem on the device (file:///tmp/examplePUIXMM/example/)
[   +9 ms] "flutter run" took 33,071ms.
[   +9 ms] Running 3 shutdown hooks
[  +32 ms] Shutdown hooks complete
[   +1 ms] exiting with code 0
wzh@wzh-pc:~/桌面/client-sdk-flutter/example$ 

@cloudwebrtc
Copy link
Member Author

hey @1056824847 ,yeah, we need another PR to fix the linux platform

daniel-g-favoreto-opl pushed a commit to daniel-g-favoreto-opl/flutter-webrtc that referenced this pull request Mar 24, 2025
)

* fix: Try to fix the non-platform thread call error.

* using hidden window for event post.

* fix.

* fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy