I am attempting to use a Tobii TX300 eye-tracker as an input device for Unity. This device is connected via LAN (TCP connection managed by Tobii SDK). The Tobii SDK has appropriate methods (I am writing in C#/mono) for opening and closing connections with the device.

I can 'play' my application once within the Unity editor and everything works as expected, but on the second attempt to 'play' the game, the editor stalls. The problem also occurs if I am currently playing the game in the editor, and then synchronize any code changes. I notice that this thread remains open:

mono.dll!mono_unity_socket_security_enabled_set+0x1e04 (there are usually at least 3-4 threads with the same name, but one always consumes a higher amount of cpu).

If I kill it manually using ProcessHacker then the Unity editor resumes normal operation.

The problem also occurs if I build the application into an executable. The game will play fine, but as soon as I attempt to exit then the application freezes, and I have to manually kill the process.

void Start ()
    eyeTracker = EyetrackerFactory.CreateEyetracker(SERVER, SERVER_PORT, SYNC_PORT, EventThreadingOptions.BackgroundThread);

void OnApplicationQuit()

Does anyone have any suggestions on why this thread is remaining open, or how to release resources within Unity scripts?


1 Answer 1


The Unity socket security is a system that attempts to ensure that Unity only connects to servers that are expecting a Unity client. This is there to reduce the ways in which Unity can be used maliciously.

In theory this should only apply when running a web build, but in practice I'm pretty sure it can run in other circumstances too, whether appropriate or not. So, check the 'Implications for use of sockets' section on this page and see if setting up the relevant security policy server helps.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .