Topic locked

iOS Memory Leak

November 5, 2021 - 3:11am #1

Hi there,

I've had several issues with building for iOS, and it loooks like a memory leak i'm having a very hard time tracking down (first i thought it was our model target that was too complex), so i decided to start a new project and run the core samples, which crashed due to memory leaking when loading the model targets scene.



However, if opening another scene first, like the image targets, and then going back and opening model targets scene, it almost always loads without issues. 

In this case the memory usage goes to 460mb, compared to > 1.4 gb when the leak is apparent.



This behavior is replicable, both with the standard model targets and with our own.

 

Project Info;



Unity 2021.1.27f1

Vuforia SDK 10.2.5



Project; Vuforia Core Samples

Platform: iOS 15.0.1

Hardware: iPhone 6S

 

iOS Memory Leak

January 14, 2022 - 8:44am #11

Hey all,

 

A fix for the issue is on it's way, probably in the next couple of weeks.

 

Kind regards,

Patrick Scheper

Technical Community Manager

iOS Memory Leak

January 5, 2022 - 8:50am #10

Sorry for the delay in response. I've reproduced the issue and our R&D is currently investigating the issue deeper. 

Until then there's sadly no workaround, other than the one mentioned below, but to wait for a fix to be released. I am sorry about that.

 

Kind regards,

Patrick Scheper

Technical Community Manager

iOS Memory Leak

December 22, 2021 - 2:29am #9

We are using

Unity version 2020.3.18f1

Vuforia version 10.2.5 already tried version 10.3.0

IOS verison 15.1 and 14.8.1

And Here is the log of the Script:

UnloadTime: 0.883792 ms

LoadAugment

LoadAugmentation:Start()

2021-12-22 11:21:07.022465+0100 IP6DetektivspielMitAr[95509:16201642] INFO/AR(0) 2021-12-22 11:21:07: Vuforia build version: 10.2.5+9122

2021-12-22 11:21:07.052583+0100 IP6DetektivspielMitAr[95509:16201642] Rendering mode set to: Metal

2021-12-22 11:21:07.123941+0100 IP6DetektivspielMitAr[95509:16201642] INFO/AR(95509) Matched precache profile for Apple, iPhone12,3, iOS 15, 800.1

2021-12-22 11:21:07.935107+0100 IP6DetektivspielMitAr[95509:16201642] INFO/AR(95509) Vuforia Fusion: Detected and enabled use of ARKit

Vuforia Initialized

Vuforia.Internal.Core.Engine:InitOnCameraReady()

System.Func`1:Invoke()

LoadAugmentation:Start()

2021-12-22 11:21:08.227267+0100 IP6DetektivspielMitAr[95509:16201642] INFO/AR(95509) Starting camera with profile for iPhone12,3, 800.1

Vuforia Started

Vuforia.Internal.Core.Engine:Start(Action)

System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

System.Delegate:DynamicInvokeImpl(Object[])

Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeDelegate(Delegate, Object[])

Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeWithExceptionHandling(Action`1, T)

Vuforia.Internal.Core.Engine:InitOnCameraReady()

System.Func`1:Invoke()

LoadAugmentation:Start()

2021-12-22 11:21:10.686347+0100 IP6DetektivspielMitAr[95509:16201883] [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke

(lldb)

Application crashes with error in Xcode: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=2098 MB, unused=0x0)

Kind regards,

pbfhnw

iOS Memory Leak

December 22, 2021 - 1:58am #8

Hey pbfhnw,

 

Is there a possibility you can share your OS version and share logs when running that script? I currently have no iOS device available and need to wait for our R&D to investigate further.

 

Kind regards,

Patrick Scheper

Technical Community Manager

iOS Memory Leak

December 21, 2021 - 11:43pm #7

No, I'm currently using the Iphone 11 and 11 Pro.

Initializing Vuforia and creating a modeltarget brings the memory usage above 2 Gb, so the App crashes.

Here the code i'm using:

 

private void Start()

    {

        VuforiaApplication.Instance.Initialize();

        VuforiaApplication.Instance.OnVuforiaStarted += VuforiaStarted;

    }

void VuforiaStarted()

    {

        modelTarget = VuforiaBehaviour.Instance.ObserverFactory.CreateModelTarget(

            "Path/to/database",

            "reference"

            );



        GameObject ar = modelTarget.gameObject;

       

        assetBundle = AssetBundle.LoadFromFile("Path", "BundleName");

      

        GameObject prefab = assetBundle.LoadAsset<GameObject>("example.prefab");



        MyPrefabInstantiator scr = ar.AddComponent<MyPrefabInstantiator>();

        scr.myModelPrefab = prefab;

       

    }

Kind regards

iOS Memory Leak

December 20, 2021 - 8:33am #6

@pbfhnw, can you confirm you're also using an iPhone 6S?

 

Kind regards,

Patrick Scheper

Technical Community Manager

iOS Memory Leak

December 20, 2021 - 4:38am #5

Hi Vuforia Team,

Is there already a solution for this problem? I'm running into the same memory problem, so my ios device crashes.

This problem occurse when im using the Observfactory api for ModelTargets.

modelTarget = VuforiaBehaviour.Instance.ObserverFactory.CreateModelTarget(

            "path/to/xml" ,

            "example"

            );

Thank in advance

iOS Memory Leak

November 5, 2021 - 10:21am #4

Hello,

Thanks for the detailed feedback. I will escalate with the team internally for review.

Thanks,

Vuforia Engine Support

iOS Memory Leak

November 5, 2021 - 8:27am #3

Another new finding;



It seems i've gotten a hacky version to work;



Using the method of launching an intermediate empty scene that just has an ARCamera with VuforiaBehvaiour on that is ENABLED, but with the defualt initialization error handler DISABLED, actually allows me to load the intermediate scene. Then from there i can click a buttion to launch the actual scene where the ONLY difference to the intermediate scene is having the model target included. 

 

There's no other way i've gotten it to work

- if the "default initialization error handler" is enabled the scene crashes. 

- if i load directly into the model target scene it crashes.

- i tried disabling the model target component and gameobject in the scene but it still crashes.

 

All of these crashes are memory leaks. The difference is around 1GB more being used by trying to launch directly into the scene... This is absurd. 

 

Can someone at Vuforia please confirm my supsions? I've tried to give as much information as possible, the next step being providing a project for you to test.

Let me know what I can do please.

iOS Memory Leak

November 5, 2021 - 6:51am #2

new findings;

With just an empty scene with a Vuforia Enabled camera i stil get run out of memory crashes.

The same scene with the VuforiaBehavior disabled launches without memory crashes. 



I tried doing ui scene launching into -> empty scene with disabled vuforia behavior - launcing into -> scene with 3d model tracking and enabled vuforia behavior.



Then the memory crashing starts when launching the last scene.



I've tried aobut everything now including delaying initialization, but the documentation for starting/stopping vuforia is next to non-existent, and the info on unity's forums is either outdated or simply not working. 



VuforiaApplication.Instance.Initialize(); does absolutely nothing when building with delayed initialization.



This is really frustrating...

Topic locked