Search Unity

Question App crashes - AR app using Google Cloud Anchors and Firebase

Discussion in 'AR' started by seyrentech, Nov 17, 2021.

  1. seyrentech

    seyrentech

    Joined:
    Jul 30, 2019
    Posts:
    5
    Hi,

    I am currently working on an Augmented Reality app for Android (and later iOS too). The app uses Google Cloud Anchors and Firebase. The basic idea is that in the first step the camera recognizes a Cloud Anchor (that has been hosted before) to place an empty object ("anchor") at the resolved cloud anchor position. After that, a request is sent to a Firebase Database to retrieve information about objects that are supposed to be positioned in the AR scene. The objects themselves are all prefabs inside the Resources folder, so only the name and the transform information (relative to the "anchor") are retrieved from the database. After that, the corresponding Prefabs are instantiated as children of the anchor so that they appear at the correct position.

    This is the point when the whole app just completely crashes. So the camera starts, the cloud anchor is successfully resolved and when the objects should appear, the app immediately crashes and I just get a general Android error message.

    But the weird thing is, sometimes it works. For example I uses standard Unity cube and sphere for testing. With the cube, everything works as intended. With the sphere, the app crashes. Both are standard objects, not modified or anything. With several other 3D Objects the app also doesn't work.

    Sometimes it even crashes earlier, before the camera even opens. So before any cloud anchor can even be resolved. But in most cases, the resolving works fine and it only stops working when the objects should be placed with the information retrieved from firebase database.

    I don't have any idea what causes this problem. Especially with this weird behavior that it works sometimes and sometimes it doesn't.

    Any held or maybe just any clue what might cause the problem would really be appreciated!

    PS: Sometimes (again not always) I get the following error message in the Unity Editor console. Not sure if this has something to do with the problem because I didn't modify the scripts that are mentioned in the message. But maybe it does


    A Native Collection has not been disposed, resulting in a memory leak. Allocated from:

    Unity.Collections.NativeArray`1:.ctor(Byte[], Allocator) (at /Users/bokken/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:69)

    UnityEngine.Networking.UploadHandlerRaw:.ctor(Byte[]) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/UploadHandler/UploadHandler.bindings.cs:95)

    Google.XR.ARCoreExtensions.Editor.Internal.ARCoreAnalytics:SendAnalytics(String, LogRequest) (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@c47d03c3b9/Editor/Scripts/Internal/ARCoreAnalytics.cs:105)

    Google.XR.ARCoreExtensions.Editor.Internal.ARCoreAnalytics:.cctor() (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@c47d03c3b9/Editor/Scripts/Internal/ARCoreAnalytics.cs:55)

    System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor(IntPtr)

    System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor(RuntimeTypeHandle)

    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes(Type[]) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:134)
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    I also experienced a crash with Google ARCore Extensions for AR Foundation. For me, it was this setup/conditions:
    1. AR Foundation 4.1.7 (not crashing with 4.2.1).
    2. Only with Development Build enabled (not crashing without it).
    3. Crash is happening when ARSession is disabled.

    Maybe this info can help in your situation.
     
  3. tichise

    tichise

    Joined:
    Apr 23, 2020
    Posts:
    5
    I have the same problem with the ARCore extension, and it's happening with AR Foundation 4.2.2, provided by ARFoundationRemote.

    ```
    A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
    Unity.Collections.NativeArray`1:.ctor(Byte[], Allocator) (at /Users/bokken/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:69)
    UnityEngine.Networking.UploadHandlerRaw:.ctor(Byte[]) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/UploadHandler/UploadHandler.bindings.cs:95)
    Google.XR.ARCoreExtensions.Editor.Internal.ARCoreAnalytics:SendAnalytics(String, LogRequest) (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@b9496c2059/Editor/Scripts/Internal/ARCoreAnalytics.cs:105)
    Google.XR.ARCoreExtensions.Editor.Internal.ARCoreAnalytics:.cctor() (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@b9496c2059/Editor/Scripts/Internal/ARCoreAnalytics.cs:55)
    System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor(IntPtr)
    System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor(RuntimeTypeHandle)
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes(Type[]) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:126)
    ```
     
  4. dhikshadani

    dhikshadani

    Joined:
    Nov 17, 2022
    Posts:
    1
    I am trying the same now, and the app crashes after resolving or sometimes before itself, after connecting to the firebase this is happening, you got it resolved? please do let know the solution?
    and as exception I am getting Resource exhausted.
     
  5. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Google owns and maintains their ARCore Unity Extensions repo, and they are not expected to monitor this forum. It might be helpful for them if you logged this as an issue.