From 3e43e52e514ef541c947d42f9fa3b684f7f3b6ad Mon Sep 17 00:00:00 2001 From: Robert Blenkinsopp Date: Mon, 30 Mar 2026 09:36:45 +0100 Subject: [PATCH 1/2] Add timeout on thread join on shutdown and suppress ThreadAbortException The timeout on the thread join matches the maximum amount of time that should be spent on a PollConnection anyway, before the thread is aborted. ThreadAbortExceptions are now explicity caught and suppressed without logging to avoid erroneous log messages in normal operation. --- Packages/Tracking/CHANGELOG.md | 5 +++++ .../Runtime/Plugins/LeapCSharp/Connection.cs | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Packages/Tracking/CHANGELOG.md b/Packages/Tracking/CHANGELOG.md index cdc993a4df..c6151e5b3c 100644 --- a/Packages/Tracking/CHANGELOG.md +++ b/Packages/Tracking/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [docs-website]: https://docs.ultraleap.com/unity-api/ "Ultraleap Docs" +## NEXT + +### Fixed +- Fixed an issue with ThreadAbortExceptions being raised during normal shutdown. + ## [7.3.0] - 25/02/2026 ### Added diff --git a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs index 2c6b681df6..57eaaaed9a 100644 --- a/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs +++ b/Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs @@ -17,6 +17,8 @@ namespace LeapInternal public class Connection { + private const uint DEFAULT_TIMEOUT_MILLISECONDS = 150; + public struct Key { public readonly int connectionId; @@ -272,7 +274,9 @@ public void Stop() //before trying to join the worker thread. LeapC.CloseConnection(_leapConnection); - _polster.Join(); + //Using a timeout for Join() to prevent the application from hanging + //if the worker thread does not exit quickly during shutdown. + _polster.Join((int)DEFAULT_TIMEOUT_MILLISECONDS); } /// @@ -308,9 +312,7 @@ private void processMessages() } LEAP_CONNECTION_MESSAGE _msg = new LEAP_CONNECTION_MESSAGE(); - uint timeout = 150; - - result = LeapC.PollConnection(_leapConnection, timeout, ref _msg); + result = LeapC.PollConnection(_leapConnection, DEFAULT_TIMEOUT_MILLISECONDS, ref _msg); if (result != eLeapRS.eLeapRS_Success) { @@ -407,6 +409,11 @@ private void processMessages() } } //while running } + catch (ThreadAbortException) + { + // Handle thread abort gracefully without logging as this can occur under normal circumstances. + _isRunning = false; + } catch (Exception e) { Logger.Log("Exception: " + e); @@ -1031,12 +1038,11 @@ public static bool IsConnectionAvailable(string serverNamespace = "Leap Service" } LEAP_CONNECTION_MESSAGE _msg = new LEAP_CONNECTION_MESSAGE(); - uint timeout = 150; - result = LeapC.PollConnection(tempConnection, timeout, ref _msg); + LeapC.PollConnection(tempConnection, DEFAULT_TIMEOUT_MILLISECONDS, ref _msg); LEAP_CONNECTION_INFO pInfo = new LEAP_CONNECTION_INFO(); pInfo.size = (uint)Marshal.SizeOf(pInfo); - result = LeapC.GetConnectionInfo(tempConnection, ref pInfo); + LeapC.GetConnectionInfo(tempConnection, ref pInfo); if (pInfo.status == eLeapConnectionStatus.eLeapConnectionStatus_Connected) { From 5870971656d88a482d251b7a2f23c3b553b80a97 Mon Sep 17 00:00:00 2001 From: Robert Blenkinsopp Date: Thu, 30 Apr 2026 11:55:50 +0100 Subject: [PATCH 2/2] Updated change log with fixed Unity 6.3 deprecation warnings --- Packages/Tracking/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/Tracking/CHANGELOG.md b/Packages/Tracking/CHANGELOG.md index c6151e5b3c..12967b4538 100644 --- a/Packages/Tracking/CHANGELOG.md +++ b/Packages/Tracking/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed an issue with ThreadAbortExceptions being raised during normal shutdown. +- Fixed some deprecated API usage of `Physics.autoSyncTransforms` and `XRStats.TryGetGPUTimeLastFrame` in Unity 6.3+. ## [7.3.0] - 25/02/2026