This repo is the sample code to reproduce error that is described in issue.
There are two different FlutterEngine from the same FlutterEngineGroup and I'm using SendPort to communicate between the engines. It works fine in the very first load even though I send the class instances that I have made. But after hot restart, I get error like below in SendPort.send(Data()) and only basic dart types are allowed(int, String...).
Invalid argument(s): Illegal argument in isolate message : (object is a regular Dart Instance)
First load before hot restart
I/flutter (21335): REQUEST from ActivityEngine::: 1
I/flutter (21335): RESPONSE from ApplicationEngine::: 2
After hot restart
I/flutter (21335): REQUEST from ActivityEngine::: 1
I/flutter (21335): RESPONSE from ApplicationEngine::: 2
First load before hot restart
I/flutter (21335): REQUEST from ActivityEngine::: 1
I/flutter (21335): RESPONSE from ApplicationEngine::: 2
After hot restart
I/flutter (24922): Invalid argument: is a regular instance: Instance of 'Data' #0 _SendPort._sendInternal (dart:isolate-patch/isolate_patch.dart:249:43)
I/flutter (24922): #1 _SendPort.send (dart:isolate-patch/isolate_patch.dart:230:5)
I/flutter (24922): #2 setApplicationEngineReceiver.<anonymous closure> (package:flutter_engine_group_project/isolate_executor.dart:23:27)
I/flutter (24922): #3 _rootRunUnary (dart:async/zone.dart:1414:13)
I/flutter (24922): #4 _CustomZone.runUnary (dart:async/zone.dart:1307:19)
I/flutter (24922): #5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1216:7)
I/flutter (24922): #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (24922): #7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (24922): #8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter (24922): #9 _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter (24922): #10 _StreamController.add (dart:async/stream_controller.dart:596:5)
I/flutter (24922): #11 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)