microsoft / MixedReality-WorldLockingTools-Unity

Unity tools to provide a stable coordinate system anchored to the physical world.
https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/README.html
MIT License
188 stars 45 forks source link

Can't disable logging in editor #246

Closed FreakTheMighty closed 2 years ago

FreakTheMighty commented 2 years ago

Based on https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/issues/205 I should be able to disable logging. But for some reason I can't get it work in editor. I've updated project settings accordingly.

image

But I still see many logs.

image

I can see that the logs do seem like they should be removed

  [System.Diagnostics.Conditional("WLT_LOG_SETUP")]
  protected static void DebugLogSetup(string message)
  {
      Debug.Log(message);
  }

But somehow it doesn't seem like the #undef WLT_LOG_SETUP is working...

fast-slow-still commented 2 years ago

Can you tell me what Anchor Manager Subsystem you are using? (ARFoundation, XRSDK, WSA) And what your version of Unity is?

Thanks!

fast-slow-still commented 2 years ago

By the way, do you have the "Null Subsystem in Editor" boxed checked in the Anchor Management Settings? You should, because that error is telling you that it is failing to start the XR system (because it's in the editor), and is going to try again. The "Null Subsystem in Editor" option tells it to use a placeholder anchor system, because the real one will fail.

fast-slow-still commented 2 years ago

I just verified it is working as expected. Two gotchas to check for:

  1. Did you hit "Apply" when you added the WLT_DISABLE_LOGGING define?
  2. Did you add the define to the settings for the current build target?
AMollis commented 2 years ago

Mark, the bug appears to be in AnchorManagerXR.cs. It's missing a line here. It's missing undef'ing WLT_LOG_SETUP when WLT_DISABLE_LOGGING is defined

#if WLT_DISABLE_LOGGING
#undef WLT_EXTRA_LOGGING
#undef WLT_LOG_SETUP  <------ Add this to AnachorManagerXR.cs
#endif // WLT_DISABLE_LOGGING

Others are likely not hitting this because they are using a different AnchorManager; for example AnchorManagerARF.cs.

fast-slow-still commented 2 years ago

@AMollis , it shouldn't matter whether it's defined in AnchorManagerXR.cs, it only matters whether it is defined in the file that uses it, in this case AnchorManager.cs, where the function DebugLogSetup() is defined.

Again, I tried this with the same configuration, and it behaved as expectedly. The two gotchas I mentioned are very easy to miss (I missed one of them the first time testing this).

AMollis commented 2 years ago

FWIW the bug went away once I added this line. I suspect it’s some quirk with how script is compiled in editor. Note, the project we repro’ed with had the “Anchor Subsystem” set to XRSDK

fast-slow-still commented 2 years ago

Yes, I was testing with Anchor Subsystem==XRSDK.

As you say, it might be a bug in Unity. As I'm sure you have noticed, WLT_LOG_SETUP isn't even used in AnchorManagerXR.cs, so whether it is defined in that file or not should have no consequence. I would suggest you file a bug report with Unity.