XRTK / com.xrtk.core

The Official Mixed Reality Framework for Unity
https://xrtk.io
MIT License
309 stars 34 forks source link

Console being spammed with XRRig warnings #911

Closed SimonDarksideJ closed 2 years ago

SimonDarksideJ commented 2 years ago

XRTK - Mixed Reality Toolkit Bug Report

Describe the bug

In both a clean project and in XRTK dev, with a scene using a configured XRCameraRig, the toolkit seems to be constantly trying to recreate the rig and in some cases creates multiple.

This causes the error described below to be spammed in to the console.

To Reproduce

(Only tested on Oculus / Android / Standalone atm)

  1. Clone Development
  2. Open Unity for XRTK-Core project
  3. Create a new Scene
  4. Use -> MixedRealityToolkit -> configure
  5. View MRTK config, especially camera profile
  6. Observe Console.

Expected behavior

No warnings if the scene has not changed

Actual behavior

Spam

Screenshots

The Mixed Reality Toolkit expected the camera's parent to be named XRCameraRig. The existing parent will be renamed and used instead.
UnityEngine.Debug:LogWarning (object)
XRTK.Services.CameraSystem.DefaultCameraRig:get_PlayerCamera () (at Packages/com.xrtk.core/Runtime/Services/CameraSystem/DefaultCameraRig.cs:125)
XRTK.Services.CameraSystem.DefaultCameraRig:get_CameraTransform () (at Packages/com.xrtk.core/Runtime/Services/CameraSystem/DefaultCameraRig.cs:85)
XRTK.Providers.CameraSystem.BaseCameraDataProvider:UpdateCameraHeightOffset (single) (at Packages/com.xrtk.core/Runtime/Providers/CameraSystem/BaseCameraDataProvider.cs:430)
XRTK.Providers.CameraSystem.BaseCameraDataProvider:SetupTrackingOrigin () (at Packages/com.xrtk.core/Runtime/Providers/CameraSystem/BaseCameraDataProvider.cs:333)
XRTK.Providers.CameraSystem.BaseCameraDataProvider:Initialize () (at Packages/com.xrtk.core/Runtime/Providers/CameraSystem/BaseCameraDataProvider.cs:169)
XRTK.Services.MixedRealityToolkit:InitializeAllServices () (at Packages/com.xrtk.core/Runtime/Services/MixedRealityToolkit.cs:1313)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Error 2 caused during build & run

Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
The following scene GameObjects were found:
Main Camera

UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Your Setup

Additional context

May take some "tweaking" to cause error to occur

SimonDarksideJ commented 2 years ago

The simple resolution to this is to ensure the rig is not regenerated in the editor unless requested.

The runtime resolution should be fine as is, since it will always be using the rig in the scene

StephenHodgson commented 2 years ago

So you're requesting to change the camera rig generation to a manual step?

SimonDarksideJ commented 2 years ago

Thought the referred PR, I actually managed to retain the automatic validation of the Rig so the issue no longer occurs. This simply moves the calls for RIg validation to areas that do not cause issue. Functionality for RIg checking still occurs as normal.

Tested

All as before validate the Rig and ensure it is setup as the Camera Config dictates

StephenHodgson commented 2 years ago

I noticed that a lot of other tools forego the automatic validation altogether, is this something we should also consider?

Only validate when someone "Configures..." or manually selects "Setup Camera Rig..."