The onLoad method is called at the same time (in terms of lifecycle) as the AttachEvent - consider something like
canvas.addAttachHandler(e -> {
// collect info here
});
It looks like you already implement that event handler interface, AttachEvent.Handler, so you're already being notified via the call to onAttachOrDetach.
The code you have already ostensibly to measure the size of the canvas isn't doing what you think it should be doing - the method call is getCoordinateSpaceWidth/getCoordinateSpaceHeight. This doesn't ask "how big is the canvas in pixels on my screen" but instead "how many pixels are in the canvas I've created. Try resizing the window - your "20x20" rectangle at position "10x10" is likely substantially larger than you would expect, because it lives within that coordinate space. You probably also notice that its borders are quite fuzzy too...
This is a common point of confusion when getting started with <canvas>, especially with high-density displays, where you would desire a bigger coordinate space than the "actual pixels" that the canvas occupies. This makes sure you are able to draw in the "sub pixels" that the screen uses to represent content.
To get the "real" size, use getOffsetWidth() and getOffsetHeight(). With those values, *tell* the canvas how big you want it to be (via setCoordinateSpaceHeight/setCoordinateSpaceWidth), but you may want to check if there are subpixels to worry about, and multiple accordingly.
GWT's Canvas is a fairly thin wrapper over the DOM's own canvas element. If you're just getting started with this, consider using elemental2's Canvas (in com.google.elemental2:elemental2-dom), and doing some reading on the browser feature itself, such as at
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas.