Catch ReferenceError in animation.py to prevent crashes