I also do not have a fix for the root problem, but I came up with another incorrect workaround that does not add delay to your code. First draw a dummy object on the canvas. Then draw animation objects (or drag objects, as this also happens when dragging and dropping). It seems that the first object drawn is permanent (that is, it cannot be cleaned correctly). With KineticJs, I do the following ... 1.) create a scene, 2.) draw an object (for example, a rectangle the size of the scene as a background. Note that the object cannot be transparent), 3.) add a layer to the scene and 4. ) run layer.draw ().
After that, I can draw anything on the canvas, and it works fine on Android. (see example below). Without a background, the object is duplicated the first time you drag it. To test it, just set the background opacity to 0).
One caveat: in my experience, this happens to the first object in any given layer. Therefore, I have to adjust each level on the stage. Depending on your application, this may or may not be better than adding time delays to the code.
This seems to be an Android bug starting with Android 4.1.x. This does not happen in 4.0.x. And this has not been fixed in a recent update to 4.1.2 posted this week. Similar problems were associated with setting the overflow-x property in CSS (see http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner % 20Summary% 20Stars & groupby = & sort = & id = 35474 ).
<script> window.onload = function() { var stage = new Kinetic.Stage({ container: "container", width: 578, height: 200 }); var boxLayer = new Kinetic.Layer(); stage.add(boxLayer); var background = new Kinetic.Rect({ x: rectX, y: rectY, width: 578, height: 200, fill: "white", stroke: "white", strokeWidth: 4, draggable: false }); boxLayer.add(background) boxLayer.draw(); var rectX = stage.getWidth() / 2 - 50; var rectY = stage.getHeight() / 2 - 25; var box = new Kinetic.Rect({ x: rectX, y: rectY, width: 100, height: 50, fill: "#00D2FF", stroke: "black", strokeWidth: 4, draggable: true, opacity: 1.0 }); boxLayer.add(box); boxLayer.draw(); }; </script>