The hard crashes appear to be happening when I call the dotnet library's Phidget.Close() function on my Phidget. At that time the logs display the following error:
Code: Select all
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at Phidget22.Accelerometer.OnAccelerationChange (Phidget22.Events.AccelerometerAccelerationChangeEventArgs e) [0x00000] in <filename unknown>:0
at Phidget22.Accelerometer.nativeAccelerationChangeEvent (IntPtr phid, IntPtr ctx, System.Double acceleration, Double timestamp) [0x00000] in <filename unknown>:0
This error is displayed whether or not I set an onAccelerationChanged handler in my C# code. When this error happens in the Close() call, the next time that I call Open() on the same Phidget object will result in the hard crash. I'm using the 126.96.36.19990130 version of the DotNet 2.0 Phidget libraries on NuGet (but the same thing happens with 20190117)
How can I flush all / wait for all pending Phidget events using the C# interface? That might resolve the issues we're seeing.
This all happens when I am running my game within the Unity editor. I press the Play button, the game runs and Opens the Phidget, then I press the Play button again (it's a toggle) and the game stops. The Editor, however, is still running and it still is holding the Phidget object
. When I hit Play again to run the game again, I see the destructors on my object getting called, and the Phidget's Close() routine running and that error displaying. The game then tries to Open() the Phidget again when my object is allocated and initialized, and then the Unity Editor locks hard.
It's a bit of an odd setup, with Unity holding onto the object in the Editor (not destroying it) and then when I allocate the new Phidget it releases the old one.
Thanks for poking at this!