Skip to content

Incorrect XRReferenceImage when using SimulatedARTrackedImage with a runtime image library #61

@ian-phoria

Description

@ian-phoria

Describe the bug
ARTrackedImageManager.trackedImagesChanged reports incorrect XRReferenceImage when utilising a MutableRuntimeReferenceImageLibrary with images downloaded at runtime.

Steps to reproduce the behavior
The situation is a bit complicated, but my layout is as such:

  • At runtime, I create a MutableRuntimeReferenceImageLibrary and populate it with downloaded textures using ScheduleAddImageWithValidationJob.
  • I then create a new SimulatedARTrackedImage for each image in the library

This all works great! The SimulatedARTrackedImages show up in the scene and inspector and display the correct images.

  • I then subscribe to ARTrackedImageManager.trackedImagesChanged and wait for an image to be added, updated or removed.

Expected behavior
When the SimulatedARTrackedImage appears in the Camera's view, the trackedImagesChanged event will run with the correct Trackable and XRReferenceImage in the added/updated lists.

Actual behavior
The trackedImagesChanged event runs, passes the correct Trackable, but the internal referenceImage (XRReferenceImage) stored in it is incorrect (it's always the same XRReferenceImage - potentially the first in the database but I've not verified it)

I believe I have been able to narrow it down to ARSimulationImageTrackingSubsystem's TryFindInLibrary method. TryFindInLibrary utilises AssetDatabase.TryGetGUIDAndLocalFileIdentifier but the Texture2D does not exist in the AssetDatabase.

The Unity docs for XRReferenceImage are quite outdated as they only talk about using a Texture2D that already exists in the AssetDatabase. The TextureGUID appears to be the issue here as that's always 00000000-0000-0000-0000-000000000000.

Versions (please complete the following information):

  • Unity 2020.3.23f1
  • ARFoundation 4.2.3
  • OS: Windows 11
  • ARSimulation 1.3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions