Currently our Metal app is making a best effort to return frame completion timestamps, near the top of the "draw" callback from the system -- here.
It seems likely this timestamp includes significant jitter. We expect each next draw call to happen some time after the previous frame completed, but there's no guarantee about when these things will be scheduled by the OS relative to each other. The system may have other priorities, besides making our MGL timestamps as accurate as possible.
We haven't dug too deep yet. It may be that the Metal API can provide us an explicit timestamp for each frame, which we could use in place of our best effort timestamps.
Or, it may be that we can do better by moving our best effort timestamps "closer to the metal". For example, there' a concept of a Metal command queue completion handler. I'm not sure if "command queue completion" has the same meaning as "frame onset" or "frame completion", but we could look into this or look for a similar callback mechanism that means what we want.
Currently our Metal app is making a best effort to return frame completion timestamps, near the top of the "draw" callback from the system -- here.
It seems likely this timestamp includes significant jitter. We expect each next draw call to happen some time after the previous frame completed, but there's no guarantee about when these things will be scheduled by the OS relative to each other. The system may have other priorities, besides making our MGL timestamps as accurate as possible.
We haven't dug too deep yet. It may be that the Metal API can provide us an explicit timestamp for each frame, which we could use in place of our best effort timestamps.
Or, it may be that we can do better by moving our best effort timestamps "closer to the metal". For example, there' a concept of a Metal command queue completion handler. I'm not sure if "command queue completion" has the same meaning as "frame onset" or "frame completion", but we could look into this or look for a similar callback mechanism that means what we want.