Fix crash when canvas is drawn before calling its context.