-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/engine
#30671Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
- On Android, implement a custom MethodCallHandler.
- Run the result.success in a new Thread on purpose, as shown in sample code below.
- All works good on both Android and Dart. (unlike calling MethodChannel#invokeMethod on Android side where you will certainly get Exceptions)
I'm asking this question because I was trying to invokeMethod to Dart side in a MethodCallHandler callback, with TaskQueue enabled. This gave me the "not on main thread exception" (as they are in DartMessenger.DefaultTaskQueue), but the MethodChannel.Result#success did not.
Expected results: This function's annotation should be better documented to explain the necessity to run on UI thread.
Actual results: The function is marked @UiThread, but no such check is done in FlutterJNI by calling ensureRunningOnMainThread, and it all works normal, making the annotation a "false alarm".
Code sample
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
"getPics" -> Thread{result.success(true)}.run()
}
}Logs
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version