Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Remote Deep Profile, can it be activated?

Discussion in 'iOS and tvOS' started by Eric-Laberge, Feb 13, 2011.

  1. Eric-Laberge

    Eric-Laberge

    Joined:
    Jan 20, 2011
    Posts:
    26
    The new remote profiling feature is a blessing on iOS, but I was wondering if I had to do something special to enable deep profiling in my build or is it not yet possible?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You can't enable it.
    but you can always use the profilers beingprofile - endprofile calls to do focused "deep profiling" where you suspect to need it for example
     
    wbknox likes this.
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Deep profiling relies on callbacks from Mono, where on compile we'll add the equivalent of CustomSampler's Begin() and End() to the beginning and end of all mono methods. Since iOS only runs IL2CPP builds, this is sadly not an option, so yes, what Dreamora said applies and you'll have to add those calls yourself. See this page for reference.

    You can still create Mono builds for Android though and these can be started with DeepProfiling enabled. Connect your phone with adb and start your game with:
    Code (CSharp):
    1. ~$ adb shell am start -n com.company.game/com.unity3d.player.UnityPlayerActivity -e 'unity' '-deepprofiling'
    on Windows/Mac/Linux builds, just start your game with
    -deepprofiling
     
  4. gramajogm

    gramajogm

    Joined:
    Jan 17, 2018
    Posts:
    2
    Correct me if I am wrong, but the activity shouldn't be com.company.game/com.unity3d.player.UnityPlayerNativeActivity?
     
    loadcomplete41 likes this.
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    I just made a Build with 2018.3.0b3 and the activity name is
    UnityPlayerActivity
    . Are you seeing a different activity name for your build? Which version of Unity are you using?
    Looks to me like UnityPlayerNativeActivity has been deprecated since 5.0?
     
  6. gramajogm

    gramajogm

    Joined:
    Jan 17, 2018
    Posts:
    2
    We are using Unity 2017.4.9f1 and using
    UnityPlayerActivity
    wasn't working for us. adb am was complaining about the activity being non existent.
    Then I found this thread and went to check our own AndroidManifest.xml and found that our main unity activity is
    UnityPlayerNativeActivity
    .
    The project I'm working on was started using Unity 5 or 4, so probably that's the reason why our manifest has the old activity? Should we change that in the AndroidManifest.xml?
     
  7. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @gramajogm UnityPlayerNativeActivity is very old, and was superceeded by UnityPlayerActivity in Unity 5.0 (if I remember correctly). So please switch to UnityPlayerActivity. In one of the latest Unity version I removed the native activity support completely.
     
    gramajogm and MartinTilo like this.
  8. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    But when trying to use deep profiling on an Android device, we get nothing but this in logcat thousands of times and the game seems to just stall in the first few frames and never advance:

    Code (CSharp):
    1. (Filename: /Users/builduser/buildslave/unity/build/Runtime/Network/PlayerCommunicator/GeneralConnection.cpp Line: 405)
    2. Can not send network message. Receiver can not keep up with the amount of data sent
    Any practical advice on really using deep profiling on Android devices successfully?
     
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    @Claytonious Is this over wifi or usb? And what version of Unity?

    In 2018.3 we've changed the profiler to only collect (and send) data for the profilers that are active in the ProfilerWindow so if you e.g. don't care about UI and Audio so much (both can be quite heavy in terms of data), you can disable their charts and reduce the load on the connection that way. I guess though that since 2018.3 is still in beta, that is unlikely a solution. There have been some other fixes & improvements on the GeneralConnection over the last year or so but I'll need to check which versions those landed on and whether they might help you, for which it would be good to know which version you're on specifically.
     
    Claytonious likes this.
  10. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    On this project, we are unfortunately still on 2017.3.4f1, so that might be the cause. I will be able to try the same project under 2018.2 very soon, so hopefully that will work as long as we turn off those extra charts to reduce the data. Thanks much for your answer, @MartinTilo !
     
  11. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    Just to verify: we do still need to build with the Mono scripting backend in order for this to work even in Unity 2018, right?
     
  12. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Yes.
    And a fix for GeneralConnection that might resolve your issue is present in 17.4.5f so in case that this fixes it already, there is no reason for you to jump in major version number. That same fix as well as the mentioned improvements through closing charts are in 2018.3 as well. 2018.2 has neither of these though.
     
    mbrsl_unity likes this.
  13. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    PSA: Deep Profiling Mono and IL2CPP Players is becoming available in 2019.3.0a10, if the player was build with that option enabled in the Build Dialog. With or without that option, this version also contains the new Call Stacks collection from players so you can debug your GC.Alloc samples without needing to take the full hit of Deep Profiling, even within players (up until now, that was only possible in the editor)

    Once you turn "Call Stacks" on in the Profiler Toolbar, newly recorded frames will contain this info. You can find the callstacks by selecting GC.Alloc samples (the totoally-non-obnoxiously, magenta colored samples) in Timeline view or by selecting them in Hierarchy view like this:
    2019-07-29_15-55-28.png
    1. Flip the "No Details" labeled drop down to "Show Related Objects"
    2. Select one of the N/A named objects (managed objects don't have a native object name, sad excuse for bad UX, I'm aware and looking at how to make this entire flow nicer and more obvious)
    3. See the callstack pop-up in a new panel below.
    Note that the N/A objects won't give you a call stack in samples other than the the ones where they occure.
    Sometimes N/A just means, this object was referenced by a sample further down the chain and/or could not be tied back from an instance ID to an Object name. This column usually contains stuff like "Main Camera" or a specific MonoBehaviour in the scene hierarchy that gets pinged if you select it, which will only work while profiling the editor.

    2019.3.0a10 still has a small bug where you might need to toggle recording on and off to get this to work, we have fixes in the pipe so this caveat should be ignored on later releases (likely fixed in a version post a12)

    Please let me know if you have any issues, concerns or suggestions on this :)
     
  14. SGJPile

    SGJPile

    Joined:
    Apr 11, 2022
    Posts:
    6
    I'm trying to enable deep profiling, but when I run this, I get the following:

    C:\Program Files\Unity\Hub\Editor\2020.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools>adb shell am start -n com.[REDACTED]/com.unity3d.player.UnityPlayerActivity -e 'unity' '-deepprofiling'

    Starting: Intent { cmp=com.[REDACTED]/com.unity3d.player.UnityPlayerActivity (has extras) }
    Error type 3
    Error: Activity class {com.[REDACTED]/com.unity3d.player.UnityPlayerActivity} does not exist.


    Note: I am able to do regularly remote profiling on the Android device.

    Any ideas on what I'm doing wrong here?
     
  15. SGJPile

    SGJPile

    Joined:
    Apr 11, 2022
    Posts:
    6
    Nevermind. We have an internal system that already sets this up.
     
    MartinTilo likes this.