Processing sketch problem-Error, disabling serialEvent() for /dev/tty.usb null

I am studying "Arduino Cookbook" about sending multi-line information (Chapter 4) by serial port.
The Processing sketch running error on Mac, but same code running OK on Windows.

The source code as below (page 106 of Arduino cookbook):

import processing.serial.*;

Serial myPort;
char HEADER = 'H';
short LF = 10;

short portIndex = 5;

void setup(){
  size(200, 200);
  println(Serial.list());
  println(" Connecting to -> " + Serial.list()[portIndex]);
  myPort = new Serial(this, Serial.list()[portIndex], 9600);
}

void draw(){
}

void serialEvent(Serial p){
  String message = myPort.readStringUntil(LF);
  
  if(message != null){
    print(message);
    String [] data = message.split(",");
    if(data[0].charAt(0) == HEADER && data.length > 3) {
      for(int i = 1; i < data.length-1; i++){
        println("Value " + i + " = " + data[i]);
      }
      println();
    }
  }
}

I make sure the port is correct, and the error happened with code "String message = myPort.readStringUntil(LF);"
Same code can run on Windows, but error on Mac.

How to solve this problem on Mac???

How to solve this problem on Mac???

Quit assuming that the same index into the serial port list is valid on both computers.