launchdarkly / flutter-client-sdk

LaunchDarkly Client-side SDK for Flutter mobile applications
Other
15 stars 17 forks source link

The 'launchdarkly_flutter_client_sdk' channel sent a message from native to Flutter on a non-platform thread. #59

Open hongfeiyang opened 11 months ago

hongfeiyang commented 11 months ago

Is this a support request? no

Describe the bug [ERROR:flutter/shell/common/shell.cc(1015)] The 'launchdarkly_flutter_client_sdk' 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.

To reproduce just include launchdarkly_flutter_client_sdk in your project

Expected behavior silence the warning

Logs If applicable, add any log output related to your problem.

SDK version

  - LaunchDarkly (9.1.1):
    - LaunchDarkly/Core (= 9.1.1)
  - LaunchDarkly/Core (9.1.1):
    - LDSwiftEventSource (= 3.1.1)
  - launchdarkly_flutter_client_sdk (0.0.1):
    - Flutter
    - LaunchDarkly (= 9.1.1)

Language version, developer tools Flutter 3.16.4, launch darkly 3.0.1

OS/platform macOS latest as of today, XCode 15.1

Additional context Add any other context about the problem here.

tanderson-ld commented 11 months ago

Hello @hongfeiyang, thank you for reporting this issue.

How frequently are you seeing this issue as a total count and as a percentage of user sessions?

Did this issue begin appearing recently? Perhaps coinciding with updating Flutter or the LaunchDarkly SDK?

Thanks!

hongfeiyang commented 11 months ago

Hello @hongfeiyang, thank you for reporting this issue.

How frequently are you seeing this issue as a total count and as a percentage of user sessions?

Did this issue begin appearing recently? Perhaps coinciding with updating Flutter or the LaunchDarkly SDK?

Thanks!

It happened recently. It's now appearing constantly when app launches. Maybe it's due to flutter's internal changes

tanderson-ld commented 11 months ago

Are you able to track down what changed recently in your code or dependencies that may have caused it? That will help tremendously in tracking this down. Thank you!

michael-joseph-payne commented 10 months ago

I also saw this today for the first time, on iOS.

launchdarkly_flutter_client_sdk: ^2.0.0

Flutter 3.16.4 • channel stable • ssh://git@github.com/flutter/flutter.git Framework • revision 2e9cb0aa71 (4 weeks ago) • 2023-12-11 14:35:13 -0700 Engine • revision 54a7145303 Tools • Dart 3.2.3 • DevTools 2.28.4

[LDEventSource] Initial reply received [LDEventSource] State: connecting -> open [ERROR:flutter/shell/common/shell.cc(1015)] The 'launchdarkly_flutter_client_sdk' 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.

I have not changed anything in the Launch Darkly code in our app for many months now because I don't have enough time to migrate to SDK 3+ right now.

rodrigobastosv commented 7 months ago

Same issue happening here:


Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.88.0)
[✓] Connected device (3 available)
[✓] Network resources
ohhyungkwon commented 2 months ago

iOS plugin seems to have an issue. The completion handler should be wrapped by DispatchQueue.main.async like below.

let completion = { [weak self] in
  DispatchQueue.main.async {
      self?.channel.invokeMethod("completeStart", arguments: nil) 
  }
}
image
tanderson-ld commented 2 months ago

Thanks @ohhyungkwon for providing more information. Are you seeing this in a reproducible manner?

ohhyungkwon commented 2 months ago

@tanderson-ld yes, it always happens to me.

tanderson-ld commented 2 months ago

Could you provide the following details?

Thank you!

ohhyungkwon commented 2 months ago

SDK version

- LaunchDarkly (9.1.1):
    - LaunchDarkly/Core (= 9.1.1)
- LaunchDarkly/Core (9.1.1):
    - LDSwiftEventSource (= 3.1.1)
- launchdarkly_flutter_client_sdk (0.0.1):
    - Flutter
    - LaunchDarkly (= 9.1.1)
Flutter Channel stable, 3.22.3
Dart SDK version: 3.4.4

The flutter screen is launched as a module by native iOS app. I don't think I spawn any other thread when I call the launch darkly initialiser.