It is because you are drawing images and not necessarily waiting for them to load.
When you refresh, the image is already loaded, so the problem goes away.
From the Mozilla tutorial:
When this script gets executed, the
image starts loading. Trying to call
drawImage before the image has
finished loading will throw in gecko
1.9.2 and earlier, and silently do nothing in Gecko 2.0 and later. So
you must use an onload event handler:
var img = new Image(); // Create new img element
img.onload = function(){
// execute drawImage statements here
};
img.src = 'myImage.png'; // Set source path