@oleguer please provide all the info requested in my link. that includes a specific example game, the image you used, the verbose log, and so forth.
that said, i don't use advmame on pi4 - i believe it is unoptimized. in the first instance you should use one of the recommended MAME/FBN emulators: https://retropie.org.uk/docs/Arcade/#step-1-choose-your-arcade-emulators
lr-fbneo is probably the best all-round performer.