I've faced the same problem with processing viewclient structures (that they can return None in unexpected places).
Another problem was in saving profiler info on old Android versions (specifically Android 4.1.2 which is the only one working with droidbox). There is no --sampling key in am commands until Android 5.0 and we should use command without it otherwise the profiler does not start. Without sampling profiler traces get quite large and so we face another problem with obtaining them after 'am profile stop'. This command seems to be asyncronous and if we pull the profiler trace file from device immediately after 'am profile stop' we get it empty. I did not find a proper solution for this and put a sleep for 3 seconds here which is enough at least on my machine.
I've faced the same problem with processing viewclient structures (that they can return None in unexpected places).
Another problem was in saving profiler info on old Android versions (specifically Android 4.1.2 which is the only one working with droidbox). There is no --sampling key in am commands until Android 5.0 and we should use command without it otherwise the profiler does not start. Without sampling profiler traces get quite large and so we face another problem with obtaining them after 'am profile stop'. This command seems to be asyncronous and if we pull the profiler trace file from device immediately after 'am profile stop' we get it empty. I did not find a proper solution for this and put a sleep for 3 seconds here which is enough at least on my machine.