4

i'm new to dart and i'm trying to run multiple algorithms using isolates to more efficiently run them multiple times, however, when calling more than one function with Isolate.spawn i start getting 'Malformed message' in the console, it still works, but i would like to know why am i getting this message, also any help in improving the code is welcome since i'm still learning the intricacies of using isolates

 stressTest()
{
ReceivePort rpDouble = new ReceivePort();
ReceivePort rpString = new ReceivePort();
ReceivePort rpInteger = new ReceivePort();
int counter = 0;
int tempoTotal = 0;

  rpDouble.listen((data) {
    counter++;
    tempoTotal += data; //data is a stopwatch.toMilliseconds
    setState(() {  //updating the "progress" and the time it took to run the algorithm in the ui
      test = counter.toString() + '%';
      _counter = tempoTotal.toString();
    });
  });
rpInteger.listen((data){
  counter++;
  tempoTotal += data;
  setState(() {
    test = counter.toString() + '%';
    _counter = tempoTotal.toString();
  });
});
rpString.listen((data){
  counter++;
  tempoTotal += data;
  setState(() {
    test = counter.toString() + '%';
    _counter = tempoTotal.toString();
  });
});

for(int i = 0; i < 5; i++) {
  Isolate.spawn(DoubleTest, rpDouble.sendPort);
  Isolate.spawn(StringStress, rpString.sendPort);
  Isolate.spawn(integerTest, rpInteger.sendPort);
}
}
}

the DoubleTest, StringStress and IntegerTest are functions that return a stopwatch.toMilliseconds integer to the sendPort.

Thanks in advance, any help is appreciated

3 Answers3

1

This happens when you want to see the Performance App. However, during the Reload app, resyncing the data results in flutter performance not getting an address or interrupting the progress reader leading to that message. This does not affect the application or your application error. If you need to read "Memory usage" or "frame rendering times" then just restart the IDE and start again.

0

As your code is running fine, so you don't need to worry much about the error. However,try reformatting your code to avoid this error message.

Aditya Joardar
  • 580
  • 5
  • 11
-1

I had a similar problem in my program. Just saving the file before 'hot restart' did the job.