LineRenderer lagging behind

Hey,

I have a few moving gameobjects and want to draw a line between them.

private void LateUpdate()
{
    UpdateRoute();
}

public void UpdateRoute()
{
    lineRenderer.positionCount = movingGameObjectList.Count;
    for(int i = 0; i < movingGameObjectList.Count; i++)
    {
        lineRenderer.SetPosition(i, movingGameObjectList*.transform.position);*

}
}
This works fine until I start to move the objects and the LineRenderer appears to lag behind a frame for some reason.
LineRenderer.UseWorldSpace is interchangable for me and does not solve the problem.
Calling the UpdateRoute() function in LateUpdate or Update apparently does not matter.
Compiling the position data into a Vector3 array and using LineRenderer.SetPositions(); does not do anything as well.
A few weeks ago I stumbled over a small forum post that said, restarting Unity solved the problem for him. And it did for me as well but now the bug is backā€¦
and the lineRenderer is lagging even in a built version of the project.
Any idea what I can do?
Are there alternatives to the Unity LineRenderer that is not GL.Lines ?

Okay, there are multiple solutions to this.

The one I used in the end uses the Application.onBeforeRender delegate like this:

private void OnEnable()
{
    Application.onBeforeRender += UpdateRoute;
}

private void OnDisable()
{
    Application.onBeforeRender -= UpdateRoute;
}

If you dont want to use delegates, another way would be to move the script on a camera of your choice and use OnPreRender().

This function will not be called if the script is NOT on a camera!

private void OnPreRender()
{
    UpdateRoute()
}

sources: