Skip to content

Commit 7b73177

Browse files
committed
Don't dare Amethyst to crash so often
1 parent 883f4e3 commit 7b73177

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

external/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0.2",
2+
"version": "1.0.0.3",
33
"display_name": "Amethyst Tracking Relay",
44
"download": "plugin_Relay.zip",
55
"changelog": "New transport layer.",

plugin_Relay/RelayDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace plugin_Relay;
2727
[ExportMetadata("Name", "Amethyst Tracking Relay")]
2828
[ExportMetadata("Guid", "K2VRTEAM-AME2-APII-DVCE-TRACKINGRELAY")]
2929
[ExportMetadata("Publisher", "K2VR Team")]
30-
[ExportMetadata("Version", "1.0.0.1")]
30+
[ExportMetadata("Version", "1.0.0.3")]
3131
[ExportMetadata("Website", "https://github.com/KimihikoAkayasaki/plugin_Relay")]
3232
public class RelayDevice : ITrackingDevice
3333
{

plugin_Relay/RelayService.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace plugin_Relay;
3030
[ExportMetadata("Name", "Amethyst Tracking Relay")]
3131
[ExportMetadata("Guid", "K2VRTEAM-AME2-APII-DVCE-TRACKINGRELAY")]
3232
[ExportMetadata("Publisher", "K2VR Team")]
33-
[ExportMetadata("Version", "1.0.0.1")]
33+
[ExportMetadata("Version", "1.0.0.3")]
3434
[ExportMetadata("Website", "https://github.com/KimihikoAkayasaki/plugin_Relay")]
3535
public class RelayService : IServiceEndpoint
3636
{
@@ -167,10 +167,17 @@ public TrackerBase GetTrackerPose(string contains, bool canBeFromAmethyst = true
167167
public void Heartbeat()
168168
{
169169
if (ServiceStatus != 0 || Host is null) return;
170-
lock (Host.UpdateThreadLock)
170+
try
171171
{
172-
DevicesToUpdate.Select(guid => _trackingDevices.GetValueOrDefault(guid, null))
173-
.Where(x => x is not null).Where(x => !x.IsSelfUpdateEnabled).ToList().ForEach(x => x.Update());
172+
lock (Host.UpdateThreadLock)
173+
{
174+
DevicesToUpdate.Select(guid => _trackingDevices.GetValueOrDefault(guid, null))
175+
.Where(x => x is not null).Where(x => !x.IsSelfUpdateEnabled).ToList().ForEach(x => x.Update());
176+
}
177+
}
178+
catch (Exception ex)
179+
{
180+
Host?.Log(ex);
174181
}
175182
}
176183

@@ -455,7 +462,12 @@ public async Task<TrackingDevice> GetTrackingDevice(string guid, CancellationTok
455462
public async Task<List<TrackedJoint>> GetTrackedJoints(string guid, CancellationToken cancellationToken = default)
456463
{
457464
if (RelayService.Instance is null) return null;
458-
RelayService.Instance.DevicesToUpdate.Add(guid); // Mark the device as used
465+
if (!RelayService.Instance.DevicesToUpdate.Contains(guid))
466+
lock (RelayService.Instance.Host.UpdateThreadLock)
467+
{
468+
RelayService.Instance.DevicesToUpdate.Add(guid); // Mark the device as used
469+
}
470+
459471
var device = RelayService.Instance.GetTrackingDevice(guid);
460472
return device.IsSkeletonTracked ? device.TrackedJoints.ToList() : null;
461473
}

0 commit comments

Comments
 (0)