Serial doesn't work

I recognize that serialEvent from the IDE example sketch of the same name. I didn't have much luck with it, either, some years back.

One thing I determined was that doing this in a while loop is unnecessary, at least it was in my projects.

What I recommend is, make a new Processing sketch entirely and a new Arduino sketch entirely and just get the serial stuff working. Stick to one datatype if you can. Did you write the Processing app? Can we look at it?
In Processing, I find it easy to send chars FROM Processing to control Arduino but Strings get pretty dodgy.
In Arduino, I find it easy to send chars or Strings to Processing, I have that bit of Processing code from post 13 if you're interested. I'll add in the Arduino side so you see what I mean.

There's a lot going on in your code, without knowing your experience and adding in that you're trying to do wifi (another hurdle unto itself), it looks to me like you're swinging for the fences and now you're lost in your code, frustrated. Been there, believe me.

The solution is to get each element working on its own, then adding in new stuff gradually. The more complicated it gets, the more carefully you add stuff in.

One last thing: forget that Arduino example sketch from the IDE. (Sorry, Arduino Mods)
Get to know the much more comprehensive examples courtesy of @Robin2
https://forum.arduino.cc/t/serial-input-basics-updated/382007