diff --git a/Packages/Tracking/CHANGELOG.md b/Packages/Tracking/CHANGELOG.md index 427555357..4735cdeef 100644 --- a/Packages/Tracking/CHANGELOG.md +++ b/Packages/Tracking/CHANGELOG.md @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated Copyright year to 2025 - Split tracking preview examples into different groups - common assets, main examples and examples that need the old input manager to work (e.g. UI input) - (Service Provider) Expose service IP and port as user settable variables +- Functions for InterpolateFrame / InterpolateFrameFromTime / GetInterpolatedFrameSize will no longer call LeapC unless a valid device is passed/set +- LeapServiceProvider Update will no longer request an interpolated frame without a valid device being set +- LeapServiceProvider FixedUpdate will no longer request an interpolated frame without a valid device and connection, bringing it into line with Update ### Fixed - Fixed some warnings around runtime variables that were only used in editor mode diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs index c3ef55ea9..03179c2c7 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs @@ -140,6 +140,9 @@ public event EventHandler LeapConnection private bool _disposed = false; + private bool _loggedNullDeviceWarningForGetInterpolatedFrame = false; + private bool _loggedNullDeviceWarningForGetInterpolatedFrameSize = false; + public void Dispose() { Dispose(true); @@ -428,7 +431,6 @@ private void handleTrackingMessage(ref LEAP_TRACKING_EVENT trackingMsg, UInt32 d } } - public UInt64 GetInterpolatedFrameSize(Int64 time, Device device = null) { UInt64 size = 0; @@ -440,15 +442,18 @@ public UInt64 GetInterpolatedFrameSize(Int64 time, Device device = null) } else { - result = LeapC.GetFrameSize(_leapConnection, time, out size); + if (!_loggedNullDeviceWarningForGetInterpolatedFrameSize) + { + UnityEngine.Debug.LogWarning($"Device is null, requesting the frame size without a valid device (handle) is no longer supported and should be considered obsolete"); + _loggedNullDeviceWarningForGetInterpolatedFrameSize = true; + } + result = eLeapRS.eLeapRS_Unsupported; } reportAbnormalResults("LeapC get interpolated frame call was ", result); return size; } - - public void GetInterpolatedFrame(Frame toFill, Int64 time, Device device = null) { UInt64 size = GetInterpolatedFrameSize(time, device); @@ -461,7 +466,12 @@ public void GetInterpolatedFrame(Frame toFill, Int64 time, Device device = null) } else { - result = LeapC.InterpolateFrame(_leapConnection, time, trackingBuffer, size); + if (!_loggedNullDeviceWarningForGetInterpolatedFrame) + { + UnityEngine.Debug.LogWarning($"Device is null, requesting an interpolated frame without a valid device (handle) is no longer supported and should be considered obsolete"); + _loggedNullDeviceWarningForGetInterpolatedFrame= true; + } + result = eLeapRS.eLeapRS_Unsupported; } reportAbnormalResults("LeapC get interpolated frame call was ", result); @@ -482,12 +492,17 @@ public void GetInterpolatedFrameFromTime(Frame toFill, Int64 time, Int64 sourceT if (device != null) { - result = LeapC.InterpolateFrameFromTimeEx(_leapConnection, device.Handle, time, sourceTime, trackingBuffer, size); } else { - result = LeapC.InterpolateFrameFromTime(_leapConnection, time, sourceTime, trackingBuffer, size); + if (!_loggedNullDeviceWarningForGetInterpolatedFrame) + { + UnityEngine.Debug.LogWarning($"Device is null, requesting an interpolated frame (from time) without a valid device (handle) is no longer supported and should be considered obsolete"); + _loggedNullDeviceWarningForGetInterpolatedFrame = true; + } + + result = eLeapRS.eLeapRS_Unsupported; } reportAbnormalResults("LeapC get interpolated frame from time call was ", result); diff --git a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs index 8fc74d058..c85c0c5c7 100644 --- a/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs +++ b/Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs @@ -669,6 +669,8 @@ protected virtual void Update() protected virtual void FixedUpdate() { + if (!checkConnectionIntegrity()) { return; } + if (_useInterpolation) { long timestamp; @@ -691,7 +693,10 @@ protected virtual void FixedUpdate() "Unexpected frame optimization mode: " + _frameOptimization); } - _leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp, _currentDevice); + if (_currentDevice != null) + { + _leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp, _currentDevice); + } } else { @@ -767,7 +772,7 @@ void HandleUpdateFrameInterpolationAndTransformation() return; } - if (_useInterpolation) + if (_useInterpolation && _currentDevice != null) { #if !UNITY_ANDROID || UNITY_EDITOR _smoothedTrackingLatency.value = Mathf.Min(_smoothedTrackingLatency.value, 30000f);