I am trying to use QML Canvas.requestAnimationFrame to draw some custom animation. I expected that the provided callback is called once for each frame, about 60 times per second. The code I have is:
Canvas {
    id: canvas
    width: 600
    height: 600
    function draw() {
    }
    Component.onCompleted: {
        var i = 1;
        function drawFrame() {
            requestAnimationFrame(drawFrame)
            console.log("Frame callback: " + i++)
            draw()
        }
        drawFrame()
    }
    onPaint: {
        draw()
    }
}
What I see is that the callback is called way more often. The counter reaches 70000 in a few seconds, after which the application becomes entirely unresponsive.
What am I doing wrong?
                        
There was a bug with
requestAnimationFrame()prior to Qt 5.9. This bug has been fixed.This code works as expected and desired to keep the canvas continuously redrawing.