Fix infinite loop when canvas setup