Search Unity

Deep Profiling on android device with Unity 2017.4.22f1

Discussion in 'Editor & General Support' started by MichalDev, Jun 7, 2019.

  1. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Hey, anyone got some experience with deep profiling on mobile devices (for the time being only android)? To be precise I'm using mono scripting backend right now and I'm building apk with auto connected profiler but as I can see there's only normal profiling possible. I also tried with adb shell commands:
    Code (CSharp):
    1. adb shell am start -n com.company.game/com.unity3d.player.UnityPlayerActivity -e 'unity' '-deepprofiling'
    ,
    but it didn't work because of some issue associated with activity not currently started (package name is provided properly). Any help would be really appreciated.
     
    alexeyzakharov likes this.
  2. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Did you try to have unity args in quotes, like this:
    Code (CSharp):
    1. adb shell am start -n com.company.game/com.unity3d.player.UnityPlayerActivity "-e 'unity' '-deepprofiling' "
    The app should be built and installed on the device - I usually use Build&Run and then relaunch the activity.

    In a meantime we are working on workflow improvements for deep profiling in players.
     
  3. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Hey, thanks for your reply. Unfortunately still the same problem:
    upload_2019-6-11_11-6-16.png
    Output is still coming from default profiler.
     
  4. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    The warning says that the activity wasn't restarted - the previous instance of the app with old args was still running and was reactivated.

    You need to kill the current instance with something like
    adb shell am force-stop <packagename>
    or through the UI
     
  5. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Oh, right. Totally forgot about that, thanks. Now it has better behaviour, intent is properly starting but it crashes after a while and after restart it starts without deep profiler attached.
     
    alexeyzakharov likes this.
  6. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    do you have a crash stack to look into?
     
  7. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Gimme a sec
     
    alexeyzakharov likes this.
  8. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    upload_2019-6-11_12-10-26.png
    So there's a culprit.Sorry for those red scribbles (mostly on package names) but I don't want to have any problems associated with NDA.
     
    alexeyzakharov likes this.
  9. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    This looks like Mono-specific - the type initializer of a networking class failed.
    Not sure why deep profiler causes this - it requires method information, but when method is called the type must be constructed already.
    Could you please file a bug report so we can investigate if this is a profiler issue.
     
  10. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    I would like to add that there's a lot of reflections going on in Networking.Client class but I can't get why it could be a problem. Without deep profiler intent is starting normally.
     
  11. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Ok, thanks a lot for your help.
     
    alexeyzakharov likes this.
  12. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Theoretically it could be some recursive class init call. The way deep profiler works is that Mono allows to instal a custom hook on method enter and leave. The profiler uses those events to record a method enter time. The only information besides time we use is a method name and class name. It shouldn't cause any recursion.
    Not sure if it is applicable, but is there an option for you to use the new Mono scripting runtime? Perhaps that could make a difference
     
    MichalDev likes this.
  13. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Yup, I will definitely check this out tomorrow morning. Thanks again!