Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

Issue with MutableRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob #882

Closed jiungerich closed 2 years ago

jiungerich commented 3 years ago

Unity bug report case number Case 1368240

Describe the bug previously added images causes issues with adding more images to a MutableRuntimeReferenceImageLibrary. As a result when the image starts to track it returns a null result for its name when it starts to track.

To Reproduce Steps to reproduce the behavior:

  1. Adds some tracked images to a tracked image session using MutableRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob
  2. Leave the session, disable it, leave the scene - do everything one can think of to reset it including ARSession.Reset.
  3. Come back to the session, set a new referenceImageLibrary and add a set of images to it using MutableRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob (this may contain some overlapping images from previously)
  4. Several of the images when tracked now only return null for ARTrackedImage.referenceImage.name even though they caused no exceptions during the add image job.
  5. Exit the app - start it again and everything loads fine
  6. try to add another image - it breaks Expected behavior Expecting setting a different lIbrary or resetting the ARSession would wipe all preprevious library information allowing new images to be loaded without issue.

Actual behavior Returns a new library name for the mutable library on return. Even though all images have been loaded into this library, there is some interference with trackimages in other libraries that never seem to clear out.

Smartphone (please complete the following information):

jiungerich commented 3 years ago

Regarding this bug. If I put in code that tracks if Image was loaded at any time by ScheduleAddImageWithValidationJob after the app has started I can avoid getting a null return. However, I can only do this if I do not change scenes. If I place the ARSession in its own scene, then leave the scene and come back then even if I track which images were previously loaded I will get a null exception intermittently upon the scene loading. This is even if the scene loaded fine previously. This happens on the second or third scene reload. On the first AR Session scene loading, all images will load fine. With the scene change, it seems that error occurs right away and the null error occurs with any newly loaded image even though it is not duplicate.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

eusebiu commented 2 years ago

Any solutions to this issue? The images can be registered only the first time; Afterwards the status is ErrorUnknown.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gruprojekt commented 2 years ago

This still exists, is there any workaround? Cause this we are loosing possibility to identify images from mutable library on scene loaded second time. The same setup on android works fine.

Unity3D-Hardik commented 1 year ago

Facing same issue with latest version , is there any solution ??

Unity3D-Hardik commented 1 year ago

@ankur-unity Do you have any solution for this ? Its blocker for me....

jiungerich commented 1 year ago

As the OP there is no solution for this - this bug just timed out. The issues are fundamental to memory structure that the image libraries are stored in and the only way to actually reset them is to close the app completely for everything to refresh. I am not sure if there will be a solution for this as I haven't heard anyone at Unity working on this. This bug has been present since the inception of AR foundation.

gilsonjess9851 commented 1 year ago
m_TrackedImageManager = GameObject.FindObjectOfType<ARTrackedImageManager>();

if (m_TrackedImageManager == null)
{
    m_TrackedImageManager = new GameObject().AddComponent<ARTrackedImageManager>();
    DontDestroyOnLoad(m_TrackedImageManager);
}

Try this It worked for me. It is important not to delete the ARTrackedImageManager and keep it as only one object.

jiungerich commented 1 year ago

umm - you were able to reset the image manager's persistent memory doing this? because that is what this bug is.

Unity3D-Hardik commented 1 year ago

Manually initialize and deinitialize works, Still, this is in the testing phase will update you once the test case is complete.

gilsonjess9851 commented 1 year ago

umm - you were able to reset the image manager's persistent memory doing this? because that is what this bug is.

For my project, yes, I don't see the Texture memory stacking. Also, I see Texture being unloaded during the unload scenes.

But be aware that UnityWebRequestTexture.GetTexture() nonReadable must be true

The main problem I had before was that the ARTrackedImagesChangedEventArgs would return null after switching scenes two or three times

DontDestroyOnLoad(m_TrackedImageManager) At least it helps me to use ARTrackedImages across scenes

Unity3D-Hardik commented 1 year ago

I was facing the same issue, sometimes we get null in the name while tracking the image, but now I did not see this kind of issue..