Skip to content
This repository was archived by the owner on Nov 16, 2024. It is now read-only.

Commit 6ce01cd

Browse files
Workaround for new OpenXR issue. (#187)
* Workaround for new OpenXR issue. OpenXR is now returning a session subsystem, but the session always (incorrectly) reports tracking state = None. Ignoring. * Update UPM generation files to v1.4.1. * Add 1 second delay in bootstrap to give ASA Spatial Anchor Manager time to finish starting before trying to utilize it. * Conditionally for Unity 2020.4 or newer, switch to new AddComponent<ARAnchor> pattern, from old anchrMgr.AddAnchor(). It looks like the AddComponent<ARAnchor> started working sometime between U2020.3.2f1 (doesn't work) and U2020.3.8f1 (does work). * Update supported versions for ASA.
1 parent 850288e commit 6ce01cd

15 files changed

Lines changed: 182 additions & 79 deletions

File tree

Assets/WorldLocking.ASA.Examples/Scenes/PinTestSofa.unity

Lines changed: 119 additions & 61 deletions
Large diffs are not rendered by default.

Assets/WorldLocking.ASA/Scripts/PublisherASA.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,13 @@ public async void Setup()
348348
asaManager.AnchorLocated += OnAnchorLocated;
349349
asaManager.LocateAnchorsCompleted += OnAnchorLocateCompleted;
350350

351+
int delayBeforeCreateMS = 1000;
352+
await Task.Delay(delayBeforeCreateMS);
353+
351354
Debug.Log($"To create session");
352355
await asaManager.CreateSessionAsync();
353356

354-
int delayBeforeStartMS = 3000;
357+
int delayBeforeStartMS = 2000;
355358
await Task.Delay(delayBeforeStartMS);
356359

357360
Debug.Log($"To start session");

Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#if UNITY_2020_1_OR_NEWER
55

6+
#if UNITY_2020_4_OR_NEWER
7+
#define WLT_ADD_ANCHOR_COMPONENT
8+
#endif // UNITY_2020_4_OR_NEWER
9+
610
using System;
711
using System.Collections.Generic;
812
using System.Threading.Tasks;
@@ -127,6 +131,14 @@ protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose
127131
Debug.Log($"Creating anchor {id.FormatStr()}");
128132
#endif // WLT_EXTRA_LOGGING
129133
initialPose = AnchorFromSpongy.Multiply(initialPose);
134+
#if WLT_ADD_ANCHOR_COMPONENT
135+
GameObject go = new GameObject(id.FormatStr());
136+
go.transform.SetParent(parent);
137+
go.transform.SetGlobalPose(initialPose);
138+
go.AddComponent<ARAnchor>();
139+
SpongyAnchorARF newAnchor = go.AddComponent<SpongyAnchorARF>();
140+
return newAnchor;
141+
#else // WLT_ADD_ANCHOR_COMPONENT
130142
var arAnchor = arAnchorManager.AddAnchor(initialPose);
131143
if (arAnchor == null)
132144
{
@@ -136,6 +148,7 @@ protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose
136148
arAnchor.gameObject.name = id.FormatStr();
137149
SpongyAnchorARF newAnchor = arAnchor.gameObject.AddComponent<SpongyAnchorARF>();
138150
return newAnchor;
151+
#endif // WLT_ADD_ANCHOR_COMPONENT
139152
}
140153

141154
protected override SpongyAnchor DestroyAnchor(AnchorId id, SpongyAnchor spongyAnchor)

Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#if UNITY_2020_1_OR_NEWER
55

6+
#if UNITY_2020_4_OR_NEWER
7+
#define WLT_ADD_ANCHOR_COMPONENT
8+
#endif // UNITY_2020_4_OR_NEWER
9+
610
using UnityEngine;
711
#if WLT_ARFOUNDATION_PRESENT
812
using UnityEngine.XR.ARFoundation;
@@ -122,11 +126,15 @@ private void Start ()
122126
#if WLT_ARFOUNDATION_PRESENT
123127
public void Cleanup(ARAnchorManager arAnchorManager)
124128
{
129+
#if WLT_ADD_ANCHOR_COMPONENT
130+
GameObject.Destroy(gameObject);
131+
#else // WLT_ADD_ANCHOR_COMPONENT
125132
if ((arAnchorManager != null) && (arAnchor != null))
126133
{
127134
arAnchorManager.RemoveAnchor(arAnchor);
128135
arAnchor = null;
129136
}
137+
#endif // WLT_ADD_ANCHOR_COMPONENT
130138
}
131139
#endif // WLT_ARFOUNDATION_PRESENT
132140

Assets/WorldLocking.Core/Scripts/WorldLockingManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class WorldLockingManager
2929
/// allowing quick visual verification of the version of World Locking Tools for Unity currently installed.
3030
/// It has no effect in code, but serves only as a label.
3131
/// </summary>
32-
public static string Version => "1.4.0";
32+
public static string Version => "1.4.1";
3333

3434
/// <summary>
3535
/// The configuration settings may only be set as a block.

Assets/WorldLocking.Core/Scripts/XR/AnchorManagerXR.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static XRAnchorSubsystem FindAnchorManager()
130130
{
131131
activeSubsystem = sub;
132132
++numFound;
133-
Debug.Log($"Start changed an anchor subsystem to running.");
133+
Debug.Log($"Start changed anchor subsystem {sub.subsystemDescriptor.id} to running.");
134134
}
135135
}
136136
}
@@ -150,6 +150,17 @@ private static XRAnchorSubsystem FindAnchorManager()
150150
/// </remarks>
151151
private static XRSessionSubsystem FindSessionSubsystem()
152152
{
153+
#if WLT_XR_MANAGEMENT_PRESENT
154+
/// Workaround. OpenXR is now returning a SessionSubsystem, but it is reporting
155+
/// its trackingStatus as TrackingStatus.None forever. Since the (incorrect) tracking status
156+
/// is all we want the XRSessionSubsystem for, leave it as null for now.
157+
bool isOpenXR = XRGeneralSettings.Instance.Manager.activeLoader.name.StartsWith("Open XR");
158+
if (isOpenXR)
159+
{
160+
return null;
161+
}
162+
#endif // WLT_XR_MANAGEMENT_PRESENT
163+
153164
List<XRSessionSubsystem> sessionSubsystems = new List<XRSessionSubsystem>();
154165
SubsystemManager.GetInstances(sessionSubsystems);
155166
Debug.Log($"Found {sessionSubsystems.Count} session subsystems");
@@ -159,7 +170,7 @@ private static XRSessionSubsystem FindSessionSubsystem()
159170
{
160171
if (session.running)
161172
{
162-
Debug.Log($"Found active session subsystem");
173+
Debug.Log($"Found active session subsystem {session.subsystemDescriptor.id}");
163174
activeSession = session;
164175
++numFound;
165176
}
@@ -174,7 +185,7 @@ private static XRSessionSubsystem FindSessionSubsystem()
174185
{
175186
activeSession = session;
176187
++numFound;
177-
Debug.Log($"Start changed a session to running.");
188+
Debug.Log($"Start changed session {session.subsystemDescriptor.id} to running.");
178189
}
179190
}
180191
}
@@ -335,8 +346,10 @@ protected override bool IsTracking()
335346
/// Currently a problem obtaining the sessionSubsystem in OpenXR. Until that is remediated,
336347
/// we will assume that if we have no sessionSubsystem, then tracking is fine.
337348
if (sessionSubsystem == null)
349+
{
338350
return true;
339-
//Debug.Log($"AnchorManagerXR F{Time.frameCount}: session is {(sessionSubsystem != null && sessionSubsystem.running ? "running" : "null")} and {(sessionSubsystem != null && sessionSubsystem.trackingState != TrackingState.None ? "tracking" : "not-tracking")}");
351+
}
352+
//Debug.Log($"AMXR F{Time.frameCount} session running={sessionSubsystem.running} state={sessionSubsystem.trackingState}");
340353
return sessionSubsystem != null
341354
&& sessionSubsystem.running
342355
&& sessionSubsystem.trackingState != TrackingState.None;

DocGen/Documentation/HowTos/Samples/WLT_ASA_Sample.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ This sample provides assets and scripts to:
2525

2626
This sample has been developed and tested using:
2727

28-
* Unity 2020.3.2f1
29-
* Azure Spatial Anchors (ASA) v2.9.0
28+
* Unity 2020.3.8f1
29+
* Azure Spatial Anchors (ASA) v2.9.0 - v2.10.2.
3030
* Mixed Reality Toolkit v2.7.2
31-
* World Locking Tools for Unity v1.4.0
31+
* World Locking Tools for Unity v1.4.1
3232
* FrozenWorldEngine v1.1.1
3333

3434
You can install WLT and this sample either from [WLT releases .unitypackage](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases) or from the Mixed Reality Feature Tool. Note that if installing from the FeatureTool, you must not only install the WLT Examples dependency (automatic), but also Import the Examples into your project. See [Installing WLT from MR Feature Tool](../WLTviaMRFeatureTool.md) for details.

UPM/asa_files/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
[See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases)
44

5+
## 1.4.1 - Workaround for OpenXR session tracking state issue.
6+
57
## 1.4.0 - Initial release

UPM/asa_files/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.microsoft.mixedreality.wlt.asa",
33
"displayName": "WLT-ASA",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"unity": "2020.3",
66
"msftFeatureCategory": "World Locking Tools",
77
"description": "World Locking Tools for Unity (WLT) + Azure Spatial Anchors (ASA)\n\nThis optional add-on to WLT leverages ASA to persist coordinate spaces across sessions and share them across devices.\nCross platform support includes HoloLens, Android, and iOS.",
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"com.microsoft.azure.spatial-anchors-sdk.core": "2.9.0",
38-
"com.microsoft.mixedreality.worldlockingtools": "1.4.0"
38+
"com.microsoft.mixedreality.worldlockingtools": "1.4.1"
3939
},
4040
"files": [
4141
"WorldLocking.ASA",

UPM/asa_samples_files/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
[See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases)
44

5+
## 1.4.1 - Workaround for OpenXR session tracking state issue.
6+
57
## 1.4.0 - Initial release

0 commit comments

Comments
 (0)