FOVE SUPPORT CENTER

Unity SDK framerate

Answered

Comments

2 comments

  • Official comment
    Avatar
    Scott Harper

    Hello, Lilian,

    I want to double-check some things first. The FoveInterface behaviours have two sets of methods for getting gaze values -- one which we lock to the current frame and poll again roughly every OnPreCull, and then a second set of methods which are intended to give you the actual current value from the C++ SDK at the time you call the method. These functions end in `_Immediate`, so `GetLeftEyeVector_Immediate()` and so forth.

     

    There's also a chance that you may be seeing problems because Unity runs all of its callbacks single-threaded. (In case you are newer to Unity's update loop, here is their documentation page with a really good diagram showing the flow: https://docs.unity3d.com/Manual/ExecutionOrder.html) So while your FixedUpdate is running 1000 times a second, at some point it will break out and let the update and OnPreCull methods run. Inside OnPreCull, we perform a delay to sync the Unity render loop with the HMD's display (70Hz) which will likely be causing further problems.

    You may also not know that Unity's `Time.time` property is designed to tell you what you expect: https://docs.unity3d.com/ScriptReference/Time-time.html That is, from within FixedUpdate, it always gives you the FixedUpdate interval, and so will always give you what you expect. A better test is to call Time.realtimeSinceStartup, which gives you a time based on your system clock and will change even within the same function. Perhaps even better is the Stopwatch class (https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.110).aspx) which is specifically designed for diagnostic timing reports.

    You definitely don't want to do coroutines, as they suffer from essentially the same problem as FixedUpdate.

    It is worth noting, however, that our SDK is fairly thread safe for most operations (we don't officially support multithreaded access at the moment, but for most uses it does quite well), and I have had good luck collected data using threads. Keep in mind that Windows's smallest granularity is 1ms, so when your thread sleeps or yields or is forced to the background there is a good chance that you'll miss more than 1ms of data. But for getting the latest eye gaze update it should be more than sufficient.

    Let us know if that works out any better for you.

    Cheers,
    -- Scott

  • Avatar
    jeremy

    Hi Lilian,

     

    I forgot to mention the other day but we have a data collection tool for Unity here: https://github.com/FoveHMD/UnityDataCollector

    It looks as though you've got your one working now, which is great to hear.

    Seasons greetings!

     

    Jeremy.

Please sign in to leave a comment.