Skip to content

EnsureCameraRig in editor constantly recreates the CameraRig #49

Description

@SimonDarksideJ

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

  1. Configure a scene for the Service Framework
  2. Expand any configuration in the Service Framework configuration
  3. The above code is run, even though an XRCameraRig does in fact exist in the active scene
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions