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

java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Binder:10909_3 #2

Closed
alisherbu opened this issue Sep 12, 2023 · 3 comments

Comments

@alisherbu
Copy link

alisherbu commented Sep 12, 2023

java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Binder:10909_3
at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:1449)
at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:1070)
at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:282)
at io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(DartExecutor.java:470)
at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:223)
at io.flutter.plugin.common.BasicMessageChannel.send(BasicMessageChannel.java:106)
at com.rohit.ble_peripheral.BleCallback.onWriteRequest(BlePeripheral.g.kt:490)
at com.rohit.ble_peripheral.BlePeripheralPlugin$gattServerCallback$1.onCharacteristicWriteRequest(BlePeripheralPlugin.kt:373)
at android.bluetooth.BluetoothGattServer$1.onCharacteristicWriteRequest(BluetoothGattServer.java:219)
at android.bluetooth.IBluetoothGattServerCallback$Stub.onTransact(IBluetoothGattServerCallback.java:256)
at android.os.Binder.execTransactInternal(Binder.java:1220)
at android.os.Binder.execTransact(Binder.java:1179)

Steps:

  1. Start advertising from first device
  2. Pair and connect as a second device
  3. call Characteristic.write([0x12, 0x34]) from second device
    And crashes in first advertisible device

Please help me!

@rohitsangwan01
Copy link
Owner

rohitsangwan01 commented Sep 12, 2023

@alisherbu seems like the characteristic write handler callback is executing on main thread
you can try to wrap this
with handler.post {} like this
If it works fine for you, the please send a PullRequest for this Fix

@alisherbu
Copy link
Author

@rohitsangwan01 #3

@rohitsangwan01
Copy link
Owner

Fixed in Version 1.0

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

No branches or pull requests

2 participants