preventing errors by calling Debug.Log on a property

Hi there.
In my project I’m animating the position and field of view of a perspective camera.
I also have a script that modifies an object’s rotation in a LateUpdate.

Quaternion To Matrix conversion failed because input Quaternion is invalid {-0.073833, 0.885253, 0.000000, 0.777146} l=1.393081

The line of code that causes this is

transform.localRotation = originalRotation

This is fine, I know why it’s giving me this error. Everything behaves as I expect as anyways.
The interesting thing is that I can get this error message to go away just by calling this line of code first:


What could Debug.Log possibly be doing that fixes my quaternion?

it may be a race condition, when you dont call debug.log your originalRotation may be undefined, and if you do debug.log it takes some time and the originalRotation has been set meanwhile.