Dynamic actor isolation (implemented in Swift 6) inserts runtime assertions into Swift callbacks if the callback is supposed to be @MainActor-isolated. The Flutter message channels API (and the FlutterBinaryMessenger class) typically takes a taskQueue parameter which if not nil, the FlutterEngine is going to invoke the callback on the thread represented by the taskQueue (and that thread usually isn't the main thread).
So when the user does this in their Swift app:
func didInitializeImplicitFlutterEngine(_ engineBridge: any FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
let channel = FlutterMethodChannel(
name: "channel",
binaryMessenger: engineBridge.applicationRegistrar.messenger(),
codec: FlutterJSONMethodCodec.sharedInstance(),
taskQueue: engineBridge.applicationRegistrar.messenger().makeBackgroundTaskQueue?(),
)
channel.setMethodCallHandler { (call: FlutterMethodCall, result: FlutterResult) -> Void in
result(nil)
}
}
and send a message to this channel in the dart program:
const MethodChannel('channel', JSONMethodCodec()).invokeMethod('message');
The program crashes (even in production) with this stacktrace, when "dynamic actor isolation" is on:

Impact
I couldn't find any related github issues.
List of code on Github that uses the makeBackgroundTaskQueue API.
"Dynamic actor isolation" is on by default if you set the Swift language version to 6:
Workaround
Tell the compiler the closure is @Sendable
channel.setMethodCallHandler { @Sendable (call: FlutterMethodCall, result: FlutterResult) -> Void in
result(nil)
}
Turn off dynamic actor isolation in release mode.
Dynamic actor isolation (implemented in Swift 6) inserts runtime assertions into Swift callbacks if the callback is supposed to be
@MainActor-isolated. The Flutter message channels API (and theFlutterBinaryMessengerclass) typically takes ataskQueueparameter which if notnil, theFlutterEngineis going to invoke the callback on the thread represented by thetaskQueue(and that thread usually isn't the main thread).So when the user does this in their Swift app:
and send a message to this channel in the dart program:
The program crashes (even in production) with this stacktrace, when "dynamic actor isolation" is on:

Impact
I couldn't find any related github issues.
List of code on Github that uses the
makeBackgroundTaskQueueAPI."Dynamic actor isolation" is on by default if you set the Swift language version to
6:Workaround
Tell the compiler the closure is
@SendableTurn off dynamic actor isolation in release mode.