We have encountered a problem when using canvas to draw polylines with IOS 16. There are two polylines with different colors. If the first one has only two vertices and they are rendered more than once, the color of the second line would become the same as the first one. Here is the demo.
<canvas width='200' height='200'></canvas>
<script>
const canvas=document.querySelector('canvas');
const context=canvas.getContext('2d');
function render(){
context.clearRect(0, 0, canvas.width, canvas.height);
context.lineWidth=10;
context.beginPath();
context.moveTo(0,0);
context.lineTo(200,0);
context.strokeStyle='#aaaaaa';
context.stroke();
context.beginPath();
context.moveTo(200,200);
context.lineTo(200,0);
context.strokeStyle='#00ff00';
context.stroke();
}
render();
render();
</script>
Here is some screenshots about this problem:
IOS 15.7:
IOS 16.0:
Does IOS 16 have any optimization strategies for this situation that would cause this problem?