Arduino resetting/hanging due to sparks in ac line
You should respect your voltage isolation. The way you have placed (and routed) resistors R16, R13 R10, R2, R31, and R4 compromises the isolation barrier created by your opto-isolators. Below I have marked your existing layout with your isolation path, which is fairly poor:
Have a single isolation zone that is as wide as possible (the width of your opto-isolators). Keep line circuits on the line side, and isolated circuits on the isolated side. See image below for suggestions.
You didn't show a schematic, but I don't see any obvious bypass caps or local on-board power supply reservoir caps. That and lack of good grounding is quite likely causing the problems.
As others have said, you should also leave proper isolation distance between the AC and DC sections, and at least try to make somewhat of a ground plane.
You have a large board with few components and large pin pitch, so routing most traces on the top layer should be fairly easy. You will occasionally have to go to the bottom layer becase in general a circuit can't be routed in a single plane. However, you can keep the traces on the bottom layer short. Consider them as "jumpers" just long enough to connect two tracks on the top layer that you otherwise can't connect in a plane. The measure of a ground plane is not how many islands it has in it, but the longest dimension of any island. Keep the jumpers short and unclumped.
However, you absolutely must put a bypass cap on every power feed to every IC. These should be small ceramic caps physically close to the IC with the overall loops as small as possible. 1 µF 0805 is about right. Not only will those be cheaper and perform better than the equivalent thru hole caps, but will be easier to solder too.
Since the DC power is coming from elsewhere and its impedance therefore suspect, put a decent size electrolytic cap right across where the power enters the board. A few 100 µF should do it.
Ground plane, ground plane, ground plane and very few excuses. Take a look how you could have done a lot of this circuit board: -
I spent about 5 minutes marking (with bright red) blue tracks that could be red with hardly any brain work at all.
I'd scrap it and start again.