Reality Collective - Reality Toolkit Bug Report
Describe the bug
There is a race condition but with the "EnsureCameraRig" function when it is run in the editor, the reason being that the "ServiceFramework.Initialise" method is executed on the background thread.
However, this requires a query to the active scene which is only possible on the UI thread, so when it queries for CameraCache.Main, it always returns a brand new Camera (because Unity....)
The Log to state it has been recreated is currently omitted in the log for the editor to prevent confusion.
https://github.com/realitycollective/com.realitytoolkit.core/blob/108eeb76c7cb801bbe210eb9dca8e7bfdc5b098f/Runtime/CameraSystem/Providers/BaseCameraDataProvider.cs#L283
To Reproduce
- Configure a scene for the Service Framework
- Expand any configuration in the Service Framework configuration
- The above code is run, even though an XRCameraRig does in fact exist in the active scene
- Don't see error when #if clause is left in
Expected behavior
If the Camera code runs on teh UI thready, the issue should not occur
Actual behavior
Because the code is executed on the background thread, the XRCameraRig is always recreated.
Reality Collective - Reality Toolkit Bug Report
Describe the bug
There is a race condition but with the "EnsureCameraRig" function when it is run in the editor, the reason being that the "ServiceFramework.Initialise" method is executed on the background thread.
However, this requires a query to the active scene which is only possible on the UI thread, so when it queries for CameraCache.Main, it always returns a brand new Camera (because Unity....)
The Log to state it has been recreated is currently omitted in the log for the editor to prevent confusion.
https://github.com/realitycollective/com.realitytoolkit.core/blob/108eeb76c7cb801bbe210eb9dca8e7bfdc5b098f/Runtime/CameraSystem/Providers/BaseCameraDataProvider.cs#L283
To Reproduce
Expected behavior
If the Camera code runs on teh UI thready, the issue should not occur
Actual behavior
Because the code is executed on the background thread, the XRCameraRig is always recreated.