Home Forums Legacy SDKs other eyeTracker.Dispose() sometimes hangs if called during calibration

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Anders [Tobii] Anders [Tobii] 2 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2271
    Profile photo of Joseph Howse
    Joseph Howse
    Participant

    I am using the EyeTracker class (from the Gaze SDK) in a WPF application. I call eyeTracker.Dispose() in the application’s OnExit method. However, the call to Dispose() sometimes hangs. This seems to happen when calibration has been started but not stopped.

    Expected behaviour: A call to Dispose() should finish safely regardless of the tracker’s calibration state. We cannot always guarantee that calibration finishes before the application terminates.

    #2284
    Profile photo of Robert [Tobii]
    Robert [Tobii]
    Moderator

    Ok, thank you for noticing.

    To me it sounds reasonable that the applications makes sure that there is no running calibration or other event handlers activated before trying to dispose the EyeTracker instance, but I am not sure if that is possible given your use case. Can you share more information about how to reproduce the problem?

    #2294
    Profile photo of Joseph Howse
    Joseph Howse
    Participant

    Part of the difficulty is that there is no synchronous method for ending calibration. If the user (or the OS) wants to close the application during calibration, I would have to try to cancel the quit event, call StopCalibrationAsync with a callback, and finally close the application in the callback. To me, trying to cancel quit events to clean up asynchronously seems like bad practice; a quit event should be interpreted as a demand to clean up synchronously. Thus, a resource such as the eye tracker should be disposable quickly and synchronously during application tear-down.

    For me, the issue is arising with an EyeTracker that is created in the constructor of App (my Application subclass), accessed from a Page subclass that listens for eye tracking data events and calls eye tracking calibration methods, and disposed in App’s OnExit method.

    #2310
    Profile photo of Anders [Tobii]
    Anders [Tobii]
    Moderator

    Hi Joseph,
    I agree that this is how a Dispose method should work, and as far as I know it is also the way it works.

    There is one quirk though: if you run the event loop on a thread of your own (that is, you use EyeTracker.RunEventLoop and not EyeTracker.RunEventLoopOnInternalThread), then you are responsible for breaking the event loop and joining the event loop thread before calling EyeTracker.Dispose.

    Please let me know how you run your event loop to help with troubleshooting.

    #2312
    Profile photo of Joseph Howse
    Joseph Howse
    Participant

    I am using EyeTracker.RunEventLoopOnInternalThread.

    #2337
    Profile photo of Anders [Tobii]
    Anders [Tobii]
    Moderator

    Hi Joseph,
    thanks for the information. I’ll try to reproduce the problem.

    #2396
    Profile photo of Anders [Tobii]
    Anders [Tobii]
    Moderator

    Hi Joseph,
    I have tried to reproduce the problem but without success.

    When you say that it sometimes hangs, how often is “sometimes”?

    I built this model application to try out what happens when the app exits while a calibration is ongoing. Can you please have a look and tell me if I do something differently from your app? Or, even better, if you can modify the code so that it sometimes hangs? I use VS2013 btw.

    Starting from a default WPF C# app, I modified the main window like so:

    And the App.xaml.cs like so:

    The app runs an infinite calibration sequence when you press the button. So the idea is to start it and then close the window.

    You can also get the window to self-destruct after a delay by uncommenting the commented-out lines.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.