Fixed a bug.

 added a checking null for Canvas.