check canvas is not null before access prev focus
check canvas is not null before access prev focus