When you resize an html5 canvas, the contents will be cleared. You can get around this by creating a second canvas without attaching it to the DOM, and then
1.drawing the original canvas on to the new temporary canvas
2.resize the original canvas (which will clear it) - make sure to use setCoordinateSpaceWidth so that the actual pixel size remains consistent with the new canvas size.
3.draw the temporary canvas onto the original canvas in the correct position
Regarding resizing on canvas and panels in general: the best way is to make sure that the entire chain of panels from the root layout panel all implement, and create a FocusWidget that implements RequiresResize, and override this method in the widget:
public void onResize() {
int width = this.getElement().getParentElement().getClientWidth();
int height = this.getElement().getParentElement().getClientHeight();
if (this.getCoordinateSpaceWidth() != width)
this.setCoordinateSpaceWidth(width);
if (this.getCoordinateSpaceHeight() != height)
this.setCoordinateSpaceHeight(height);