Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

ARKit CPU Usage

Discussion in 'AR' started by dlazares, Nov 25, 2017.

  1. dlazares

    dlazares

    Joined:
    Jul 24, 2017
    Posts:
    3
    I've noticed in Xcode that the CPU usage on my app was extremely high (often bouncing above 100%) and thought I must have done something wrong, so I built the unity AR shadow example and noticed that the CPU usage for this was also extremely high (bouncing from 80% to above 100%). I'm currently running this on iPhone 7 Plus with Xcode 9.1 and the latest Unity-ARKit-Plugin.

    Has anyone else experienced this and have any tips on how to reduce the CPU usage?

    I am currently trying to implement a native sharing feature based off https://github.com/ChrisMaire/unity-native-sharing and it keeps crashing due to what I believe is the high CPU usage. I have profiled and debugged my code to make sure that it is not the one hogging the CPU.
     
  2. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    It's unlikely to crash due to high cpu usage. Why don't you run it in XCode and see what is output when it crashes? Usually you will have a callstack that points to the culprit.
     
  3. TomKhan3

    TomKhan3

    Joined:
    Jul 21, 2017
    Posts:
    18
    I'd like to jump in on this chat an tell you of my experiments which show the Unity ARKit Plugin has performance issues compared to native ARKit examples using XCode 9.1, Unity 2017.1.1f1 and iPhone 6s with iOS 11.1.

    The first set of tests I used the Example projects from Apple at https://developer.apple.com/arkit/. With the exception of one, these examples (like the one where a lamp or cup is put in the scene) use only 40-50% of the cpu. The one project which rises to 80-90% cpu usage is the Interactive Content project where an animated iguana is in the scene.

    The basic UnityARKitScene uses between 95-130% of cpu which had me thinking the planeDetection was costing a lot. This can't be entirely the reason though since the Apple AR Basics project has plane detection and uses less than 50% of the cpu. This performance gap is a big deal because when the cpu usage on the phone is > 100%, XCode starts pumping out "World tracking performance is being affected by resource constraints [1]" and the object placed in the scene starts to lose tracking. Basically, the object (even a cube) starts looking like it is floating around struggling to keep it's anchor. In a custom FocusSquare scene I'm working on, once a plane is found you can tap the screen and planeDetection turns off (new session is started with planeDetection off) and a simple 3D model (with no animation) is put down. Even with planeDetection off the scene runs at > 110% cpu usage almost the whole time.

    Has there been any insights into improving the performance of scenes which use the ARKit Plugin to get in the same performance ball park as the native ARKit examples?
     
    jessevan and daniilkorotin like this.
  4. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    That does sound pretty bad - let me take a look at that.
     
  5. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Any update on this? I'm working on an AR project, testing without AR features first, so haven't implemented the ARKit plugin features yet. But would like to know if you found anything that was causing the CPU performance hit mentioned above?
    Cheers
     
    TomKhan3 likes this.
  6. TomKhan3

    TomKhan3

    Joined:
    Jul 21, 2017
    Posts:
    18
    I would also like to ask if there's an update regarding the performance of the plugin. The cat in my little game (https://itunes.apple.com/us/app/kitty-paradise-ar-cat-care/id1274256747) is placed on a plane but is barely holding on to it's anchors as XCode starts listing the "World tracking performance is being affected by resource constraints [1]" error messages. Sometimes the plane floats away...

    The important indicator that there is a problem with the plugin is that the basic example scene the plugin comes with also behaves this way.
     
  7. super77gg

    super77gg

    Joined:
    Sep 25, 2014
    Posts:
    46
    Would love to know if there is an update on this as well - definitely hitting the 100% cap w/ a very minimal scene, causing tracking to slip...
     
  8. ZikW

    ZikW

    Joined:
    Aug 18, 2014
    Posts:
    18
    Same issue here, CPU usage > 100% with the UnityArkitScene from the Arkit plugin.
    Ipad 5th gen
    iOS 11.3
    Xcode 9.3
    Unity 2017.3.1p4
     
  9. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    4,000
    same here too 2017.3.1
    and 2017.4 LTS too
     
  10. Hadrien-ESTELA

    Hadrien-ESTELA

    Joined:
    Nov 10, 2016
    Posts:
    6
    Empty scene with this simple call use +100% CPU:

    extern "C"
    {
    void* CreateSession ()
    {
    ARSession* session = [ARSession new];
    ARWorldTrackingConfiguration* conf = [ARWorldTrackingConfiguration new];
    [session runWithConfiguration:conf];
    return (__bridge_retained void*)session;
    }
    }

    With SceneKit this is taking less than 50%.
    Why ARKit usage from unity take so much resources ?!
     
  11. dustin_red

    dustin_red

    Joined:
    Feb 7, 2018
    Posts:
    46
    Not sure if this is related, but I'm getting exceeding wakeups limit crashes while using the Unity ARKit plugin. Searching online, the wakeups limit is memory or multi-threading related. Is this because calls from native ARKit to Unity ARKit are too CPU intense?

    Unity 2017.3.1f1, iOS 11+

    Crash log from iPhone X:

    Code (CSharp):
    1.  
     
  12. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    @jimmya @timmunity Any update on this? Are you guys getting same issues on your end? Is it solved by pending native integration/AR Utilities?

    Cheers
     
  13. jessevan

    jessevan

    Joined:
    Jan 3, 2017
    Posts:
    35
    @jimmya I'm seeing something similar. In XCode CPU usage starts around 80% then grows to over 100% finally resulting in world tracking issues. When the unity debugger is connected it reports CPU usage of just ~2ms or (1000fps). This has been an issues I've been tracking for a while. I assumed it was somewhere in my app, but perhaps there's something going on in the plugin.
     
  14. jessevan

    jessevan

    Joined:
    Jan 3, 2017
    Posts:
    35
    I've been struggling with performance for a while now and can't seem to nail down what's going on. Generally I find the performance to degrade over time, but haven't found the source of this.

    Here's what I've found so far:

    * The example ARKit scene runs at 50% CPU on my iphone x, its pretty consistent. I haven't compared this to native arkit yet
    * I was using Unity's physics cast against detected planes. Switching to ARkit's hit test is an improvement
    * Disabling the `Get Point Cloud` improves performance
    * My app starts between 70-80% and at some point spikes to 100-200% CPU usage
    * When I look at the profiler, either in the editor or when connected to the device I can't find the offending code
     
    macdude2 and GreeneMachine like this.
  15. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    106
    Just installed 2017.4.4f1 and I'm seeing this consistently when ARKit is running. I was previously using 2017.4.1 without issue. The crash when Xcode is attached is reported as a "memory issue", but the crash logs complain about wakeups. This is on an iPhone X.

    Event: wakeups
    Action taken: none
    Wakeups: 45001 wakeups over the last 221 seconds (203 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds
    Wakeups limit: 45000
    Limit duration: 300s
    Wakeups caused: 45001
    Duration: 221.32s
    Steps: 87

    Hardware model: iPhone10,6
    Active cpus: 6
     
  16. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Anyone from Unity care to respond to this? At least to say if you are experiening the problem?
    Surely all the unity built ar ios apps that have been released are not suffering these crashe... perhaps you could post any noteworthy build settings we should make sure we have set correctly for ios builds integrating arkit?
     
  17. dyuldashev

    dyuldashev

    Joined:
    Mar 3, 2016
    Posts:
    76
    I am also facing similar issues. I am using Unity 2017.4.4f1 and iPad 2017. XCode 9.3.
    It starts working properly, but overtime, the detection gets very slow, and the planes slip away sometimes.
    Worst of all, my app is crashing after being used for a few minutes.
    I don't know the source of these issues. Would you, Unity devs, take a closer look at this issue?
    Thanks. @jimmya @timmunity
     
  18. skyyguy

    skyyguy

    Joined:
    Apr 28, 2016
    Posts:
    1
    I'm experiencing the same - very low FPS with virtually nothing in scene. Whats up Unity?
     
  19. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,021
    Last edited: Jul 5, 2018
  20. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    Anyone having luck resolving this issue? I'm having a similar slowdown with ARKIT 2.0 and unity 2018.2.6. After using the app for about 5 minutes, we get slowdowns. At the start of the game we get around 200fps in the profiler, after 5 mins its down to about 30fps. The issues aren't experienced when running the game without ARKit
     
    Last edited: Sep 21, 2018
  21. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    Not sure if this will help anyone, but we resolved our issue by forcing 720p using UnityARVideoFormat. We can play for much, much longer durations without resources ticking up. Obviously would be great to play at max res, but we are happy for now.
     
  22. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    138
    I'd just like to add my weight to this thread.
    I'm burning CPU and getting the 'limited resources' warning when running the WorldMapper scene on a 2018 iPad running iOS 12.1(beta). I have plane detection turned off and have not models in the scene, just the world mapping and the particle-based pointcloud.

    I will try limiting the video to 720p to see if this helps.

    But it would be nice to get the CPU usage of the Unity-based examples down to something like the Xcode samples.
     
    ROBYER1 likes this.
  23. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Hi, could you please share how you forced 720p? I can't see where the UnityARVideoFormat struct is being used within the ARKit scripts.
     
  24. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    hungrybelome likes this.