Fix java.lang.ClassCastException in requestAnimationFrame