Taking the ignition wires this close to the Arduino is likely the reason. The controller faces electrical disturbance.
How exactly does the UNO get its power?
I once, 35 years ago, did the similar to a 4 stroke car and it still worked when removed from the car 10 years later. I remember I used an optocopler. Likely it was situated in the engine bay. I did have an oscilloscope at hand.