How do you think it got there? Read the forum guidelines. Your code uses a core library, which means it should be in the core library questions section.
On topic. There are a lot of problems with your code, besides the fact that all the empty lines make it hard to read. But one of the main problems is probably that you continuously reload the maskImage in EVERY draw() and in EVERY object instance. This is already causing slowdown in your program. When the movie restarts at the beginning this is probably causing some more slowdown, which probably causes some sync issues between the movie read and the main draw() loop. Try moving m.read(); to the beginning of the draw() loop instead of in the movieEvent method. And make sure you only load the maskImage ONCE in setup().
On topic. There are a lot of problems with your code, besides the fact that all the empty lines make it hard to read. But one of the main problems is probably that you continuously reload the maskImage in EVERY draw() and in EVERY object instance. This is already causing slowdown in your program. When the movie restarts at the beginning this is probably causing some more slowdown, which probably causes some sync issues between the movie read and the main draw() loop. Try moving m.read(); to the beginning of the draw() loop instead of in the movieEvent method. And make sure you only load the maskImage ONCE in setup().