I'm working on an HTML5 canvas app that contains shapes that I fill with images. It's a framing tool, for building and previewing custom frames.
Everything works great on desktops/laptops, but when I switch to iOS devices, I'm getting the following strange behaviour.
Sometimes, a thin white line appears at the border where the image that I'm using to fill the shape repeats.
See the following JSFiddle: http://jsfiddle.net/3TVSy/3/
HTML:
<canvas id="canvas2" width="100" height="500" style="vertical-align:top"></canvas>
<canvas id="canvas1" width="300" height="2000" style="vertical-align:top"></canvas>
Javascript:
jQuery(function($){
var $canvas = $('#canvas1'),
$canvas2 = $('#canvas2'),
scale = {scale: 0.21688837478311163, x: 0, y: 0},
side = {
fillStyle: '#222',
x1: 0,
x2: 266,
x3: 266,
x4: 0,
y1: -4.610666666666667,
y2: 261.38933333333335,
y3: 1538.898666666667,
y4: 1804.898666666667,
}
;
$canvas.createPattern({
source: "http://vps5960.inmotionhosting.com/~romamo5/wp-content/uploads/2012/12/286-ft.jpg",
repeat: "repeat-y",
// Draw frame when pattern loads
load: function(ptrn){
side.fillStyle = ptrn;
$canvas.clearCanvas()
.drawLine(side)
;
$canvas2.clearCanvas()
.scaleCanvas(scale)
.drawLine(side)
;
}
});
});
The fiddle has two versions of the canvas. The larger one is not scaled, and the smaller one IS scaled. The artifact only appears on the smaller one (and only on actual iOS devices, not the simulator). You can see the thin white line on the smaller canvas about 90% of the way down.
I have to scale the image, so not scaling is not an option. I've also noticed that if I round the scale factor in the fiddle to just three decimal places, then the artifact disappears. Problem is, if I do that rounding, my frame tool really starts to mess things up on subsequent sides, so rounding also really isn't an option.
I'm using jCanvas to do the drawing, but I don't suspect it's the problem. It's just a wrapper to all of the native canvas methods. (Edit: confirmed, the artifact appears even if not using jCanvas - see http://jsfiddle.net/3TVSy/5/)
Has anyone else seen/solved this problem? Is this a bug in the iOS browser?