os_signpost works on simulator but not when running on device
Asked Answered
C

2

9

I have the following lines of code in one of the functions I want to track time for, using instruments. When I run the app on simulator from instruments, the measured times with os_signpost do show up and I can accurately measure what I need.

Then I switch to device, same code. However, as it runs on device instruments does not show the measured times. It only show this: enter image description here

the os_signpost times do not show up at all.

So, all works great on simulator, but not when I switch to my iPhone device.

Any idea?

let spid = OSSignpostID(log: SignpostLog.myLog, object: myObj as AnyObject)

defer { os_signpost(.end, log: SignpostLog.myLog, name: "operation1", signpostID: spid) }

os_signpost(.begin, log: SignpostLog.myLog, name: "operation1", signpostID: spid)
Chromic answered 5/12, 2018 at 21:58 Comment(0)
E
10

Make sure you did not disable OS_ACTIVITY_MODE via an environment variable (see screenshot below)

Do not do this, or signposts will not work

I removed it and everything worked =)

Embryonic answered 24/7, 2019 at 16:16 Comment(2)
it's better to set it 'default' instead of 'disable', setting 'enable' will show each and every log, but disable will also disable every log (even useful logs from pods), so better use 'default' as it will only hide useless logsMetagalaxy
oh, man. I've spent hours until I found your solution. Thanks!Atreus
C
2

Turns out os_signpost would not show up because the recording was set to immediate. Setting it to Deferred made it so I could run the app, then stop recording and then instruments shows the custom os_signpost I had in code.

enter image description here

Chromic answered 7/12, 2018 at 17:46 Comment(2)
@Shizam Note that in general, when you're not seeing any recordings, there is a big chance that below the title of the Instruments window there is a ⚠️#number. When you click on it, it will show messages like "Data stream: 3 log/signpost messages lost due to high rates in live mode recording. Try windowed recording mode." The "high rate" refers to generating too many signposts per second—more than the device can handel atm.Raggedy
@Chromic setting recording mode to 'Deferred' does not work for me. I still cannot see my signposts while profiling on the device.Schmit

© 2022 - 2024 — McMap. All rights reserved.