Xamarin profiler broken on Android?

FlorianGiraultFlorianGirault JPMember ✭✭

Hello all,

I am struggling to use the Xamarin profiler on Android to help us check memory issues in our app.

The problems I encounter:
1) Manual snapshots don't work
2) Application is not stable when launching a profiling session with automatic snapshots (either time or GC).
- On one device it crashes maybe one minute after fully booting the application.
- On another device it will hang during application boot.

I found the following blog entry that points out the same issue as [1]: manual snapshot don't work, and they also point out an issue that looks close to issue [2].
https://fireseed.com/blog/2016/02/12/xamarin-android-memory-problems/

Is it completely broken or are there people for whom it works?

I was thinking that maybe it would be more stable if I could take the snapshots directly on the device without the GUI front end: Is there a way to collect mlpd data on the device without being connected to PC, so that I can take local snapshots and logs during a test session and then transfer the mlpd to a PC to study it?
I remember that before the Xamarin Profiler we could enter parameters for mono to enable profiling.
Like the parameter below:
--profile=log:calls,alloc,output=output.mlpd,maxframes=8,calldepth=100

Can we still use that? Where should we put the parameters? (maybe in Environment.txt??? I forgot...)

I use Xamarin.Android 7.2
Xamarin.Android 7.2.0.7 (b16fb82)
Visual Studio extension to enable development for Xamarin.Android.

Posts

  • RodrigoMoyaRodrigoMoya ESXamarin Team Xamurai

    That "snapshots are broken on Android" problem was fixed almost a year ago, so what version are you using of the Xamarin Profiler?

    Also, when profiling Android apps, have a look at the Console tab, which includes the whole Android log, and which would help in diagnosing what the problem is.

  • FlorianGiraultFlorianGirault JPMember ✭✭

    Hello Rodrigo,
    Good to hear that it should work.

    I'm using a fresh install of VS2017 and Xamarin.Android 7.3.1.2.

    I gave up profiling directly from the profiler but started to use the old way: setting the debug.mono.profile property like follow:

    setprop debug.mono.profile log:sample=cycles/100,alloc,heapshot=1gc,port=60001,output=/sdcard/p.mlpd

    When using parameters like the above it works fine.

    It looks like I have stability issues when using the "calls" parameter. That may explain why I can't profile from the GUI.

    Anyway at the moment I think I can use the profiling results now and it looks stable enough for my purpose.

    PS: I have to use an old android (4.4.2) so maybe it is the reason why I encountered this issue.

    Also, when profiling Android apps, have a look at the Console tab, which includes the whole Android log, and which would help in diagnosing what the problem is.

    Indeed when it crashed there was information in the android log but it was like a native crash, with a bunch of memory state and addresses.
    I don't have a crash log now but if I get another I will post it here.

  • RodrigoMoyaRodrigoMoya ESXamarin Team Xamurai

    That's very much what the Xamarin Profiler does, and yes, using 'calls' is a bad idea, as it slows down the app too much to be of any help for profiling performance issues, apart from generating huge MLPDs.

    The Xamarin Profiler doesn't use method enter/leave (= "calls" argument to mono profiler) anymore, so if the Profiler logs are showing that being passed, I wonder if you are using an old Xamarin Profiler version, which used method enter/leave on Android for time profiling. Could you please check the profiler logs under %localappdata%\Xamarin\Logs (IIRC)?

    Also, another difference is that we don't pass the port, we let the runtime decide what port to use, but that shouldn't matter for your problem.

    About Android 4.4.2, AFAIK if you have a recent Xamarin.Android being used by your app, the snapshots-hangs-the-app error shouldn't happen, but it might be some native stuff instead, so can you, if possible, do a quick test of everything you have, but on a newer Android simulator/device instead of that 4.4.2?

Sign In or Register to comment.