Instruments OSSignpost intervals not recording or displaying

I'm trying to use OSSignposter to capture intervals in our app for use in Instruments. The sample code here works in a new project. I see the intervals, signpost icons, etc. However, this same code (integrated into a much bigger app) does not record or display ANY intervals.

I can get the config status on both apps' oslog configuration, and there's no difference.

sudo log config --status --subsystem **.*******.*******.signposttest
Mode for '**.*******.*******.signposttest'  INFO PERSIST_DEFAULT

I've checked both workspaces and schemes. There is no difference between these projects. The only thing I can think of at this point is a build setting that could affect it. (I'm not using OS_ACTIVITY_MODE = disable but have during the lifetime of this app).

Perhaps it's a provision profile issue? Entitlements? However, I've tried profiling in debug mode with debug provision profile and got the same results.

Not seeing any signpost activity is happening in immediate mode and deferred mode. I see events in the bottom pane in "List: Events" view. In the last n seconds mode, there is no data, no lanes, and nothing on the timeline.

Here's the sample code. I tried in both projects.


import os.signpost

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var blackWindow: UIWindow?
    var alertWindow: UIWindow?
    static var originalAppDelegate: AppDelegate!

    var signposter: OSSignposter
    var signpostInterval: OSSignpostIntervalState?

    override init() {
        signposter = OSSignposter(subsystem: Bundle.main.bundleIdentifier ?? "unknown", category: "app")
        signposter.emitEvent(#function)
    }


  func applicationWillResignActive(_ application: UIApplication) {
        guard let interval =  signpostInterval else {
            assertionFailure("no interval")
            return
        }
        print("backgrounding, ending active state")
        signposter.endInterval("active", interval)
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        signpostInterval = signposter.beginInterval("active")
    }
}

Working

This is what I expect to see, signposts and intervals.

Not Working

However, this is the sample code run in the non-working project.

If I programmatically check if the OSSignposter is enabled, I get false. I have no idea how this has been disabled externally, as I'm not explicitly disabling OSSignposter. I also do not see a way to programmatically enabled it.

signposter = OSSignposter(subsystem: Bundle.main.bundleIdentifier ?? "unknown", category: "app")
assert(signposter.isEnabled)

This always asserts. Any help would be very much appreciated.

Post not yet marked as solved Up vote post of bslayerw Down vote post of bslayerw
2.0k views

Replies

The sample code here works in a new project. I see the intervals, signpost icons, etc. However, this same code (integrated into a much bigger app) does not record or display ANY intervals.

Did you test app have the same bundle ID as your real app? If not, create a new test app with the same bundle ID and see if that has the same problem. That’ll tell you whether the issue is tied to your real app’s bundle ID, or something else about that project.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo Thanks for the prompt reply! I just tried creating a new project with the same bundle ID, even using the same team and provisioning profile, and it works fine. So it must be something specific to the app. I also tried both deleting the subsystems config file, using a default config, and then also explicitly settings specific categories for these subsystems. Still nothing. I have also tried adding a project to the same workspace, which works fine. So it must be project or target related?

Additionally, I checked in the logging preferences folder and first removed the plist for the subsystem there to test. That did not affect it. I also created an explicit config for the subsystem and categories with no effects. I placed a plist with our subsystems name here: `/Library/Preferences/Logging/Subsystems/{bundleID}.plist, with this:

<dict>
    <key>DEFAULT-OPTIONS</key>
    <dict>
        <key>Level</key>
        <dict>
            <key>Enable</key>
            <string>Info</string>
            <key>Persist</key>
            <string>Inherit</string>
        </dict>
    </dict>
    <key>analytics</key>
    <dict>
        <key>Level</key>
        <dict>
            <key>Enable</key>
            <string>Debug</string>
            <key>Persist</key>
            <string>Inherit</string>
        </dict>
    </dict>
    <key>app</key>
    <dict>
        <key>Level</key>
        <dict>
            <key>Enable</key>
            <string>Debug</string>
            <key>Persist</key>
            <string>Inherit</string>
        </dict>
    </dict>
</dict>

So it must be project or target related?

It seems that way. And nothing immediately obvious springs to mind. The one thing that might affect this — having the signpost code in a shared library — was ruled out by the code in your first post where you do this in your app delegate.

In situations like this I generally start hacking on the two projects, removing stuff from the failing one and adding stuff to the working one until I isolate the cause, but that can be a lot of work.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Yes, I was hoping to avoid it. This project is not small. Does anything spring to mind if I said that the project was started 7-8 years ago? Maybe something new was added that this old project file is missing, I'm going to have to do just that, though. Comparing build settings. Thanks, @eskimo!

Add a Comment

Hi there,

It seems like you did try quite a few things already. E.g. making a new test app that logs to the same subsystem

Did you try the other way round as well, to make your main app log to another subsystem and see whether those signposts get logged? This would let you know whether it's specific to this subsystem or to your app.

Also note that the log levels are only a concept of os_log not of os_signpost (or OSSignposter respectively). To turn on signposts, you need

<dict>
  <key>DEFAULT-OPTIONS</key>
  <dict>
    <key>Signpost-Enabled</key>
    <true/>
  </dict>
</dict>

(you can use the same key in the specific configs for categories as well)

I don't expect this to make a difference in practice as you already said that you also tried deleting the signpost plist file for your subsystem, but it seems worth a try, to experiment with that key as well.

Also, it seems like log config --status sadly doesn't seem to show the signpost enabled/disabled state.

Which brings me to another thing to try: Did you try logging to the same subsystem? It might be that your issue is signpost-related (in contrast to os_log), not dependent on which subsystem you use.

Furthermore, I recommend trying out other solutions to look at the signposts stream apart from Instruments. E.g. you can try log stream --signpost to stream log messages and signposts (by default it only streams the log messages in this mode). E.g.

log stream --signpost --process Maps --predicate "subsystem='com.apple.coreanimation'"

Or use something like

sudo log collect --last 1m

to capture a .logarchive and then open this .logarchive with Instruments to see whether it contains your expected signposts.

Some of this looks like it might be a bug.

Looking at the Instruments screenshot of your non-working example, we can see that there are 4 events in the list for your subsystem and the category "app". I'd be interested how many intervals there are. When you switch to the "List: Intervals", how many intervals are in the list?

So Instruments show 4 events in the list, but it doesn't draw any in the timeline area above. The timestamp gives us a clue why: The first event appears at 300072:33.464, so over 300,000 minutes after the start of the recording. But your recording is only 1 minute and 10 seconds long, so this value doesn't make sense.

If your "List: Intervals" list also shows the intervals you expect (but they are not rendered in the timeline) then the issues is related to the wrong timestamps. Instruments just tries to draw the interval/event marker outside of the current visible time interval. If it doesn't show any intervals, then it is two separate bugs. (Bug 1: Wrong timestamp for events, Bug 2: Intervals aren't captured at all. Although if the timestamps are wrong, this could potentially also explain missing intervals. If the end of an interval occurred before the begin, then Instruments wouldn't show it either)

I hope this allows you to track down the issue.

If you find a way to reproduce the invalid timestamps, please file a feedback via https://feedbackassistant.apple.com/. If you cannot find a way to reproduce it with an a project you are comfortable to attach to a feedback report, please still file feedback that includes the .trace file with the invalid timestamp. Maybe we can find something in the trace file that explains why the timestamps are wrong.

Thank you for taking a look at this. I followed the suggestion about using the non-working bundle id / subsystem in the working app and visa versa, that That did not change the behavior.

os_log calls also have erroneous timestamps, so it's not just a sign posts. I tried streaming the logs to the terminal, but using the subsystem predicate and process does not print anything to the terminal. Console.app does not show any results with the same filter/predicates. I'm definetly seeing other apps subsystems working as expected.

log stream --signpost --process OurApp --predicate "subsystem='com.****.***.***.****'"

I have also diffed the working and non-working project.pbxproj files looking for anything that stands out. I did not see anything obvious but then again, I really don't know what I would be looking for.

Additionally, I removed the entire DerivedData folder, reset the package cache, and rebuilt the app. I'm not sure what else to try.

I've submitted feedback with a trace of the behavior and the offending project file to https://feedbackassistant.apple.com/. Here's the Feedback id: FB11502277

Thanks!

  • Oh, and also to reply to this question.

    "Looking at the Instruments screenshot of your non-working example, we can see that there are 4 events in the list for your subsystem and the category "app." I'd be interested in how many intervals there are. When you switch to the "List: Intervals," how many intervals are in the list?"

    When switching to List: Intervals, there are none.

Add a Comment

Hey @bslayerw

Can happen you use xcconfig files? And your app bundle id is fetched from there?

I'm dealing with the same exactly issue. Can see .event and can not see .begin.end traces.

Have you found out what was the issue in your case?

  • @osxd Yes. I can see events emitted, but not intervals. There are two things to note in my case. Due to a legacy requiring 3rd party library, I'm forced to work with Xcode in Rosetta. The other thing which might be the cause, but I don't know the source, is that the timestamps are erroneous. They're far off in the distant future. You can see some data for the intervals in Instruments. I'd point you there, but I'm troubleshooting some weird Xcode issue, all my simulators have disappeared.

Add a Comment

@osxd Yes. I use the xcconfig files cocoa pods generates. I can see events emitted, but not intervals. There are two things to note in my case. Due to a legacy requiring 3rd party library, I'm forced to work with Xcode in Rosetta. The other thing which might be the cause, but I don't know the source, is that the timestamps are erroneous. They're far off in the distant future. You can see some data for the intervals in Instruments. I'd point you there, but I'm troubleshooting some weird Xcode issue, all my simulators have disappeared.

I am still experiencing this issue. I gave up and intend to come back to it soon. I have a feedback thingy (ticket?) open using the Feedback Assitant app, if it's any help this is the feedback id: FB11502277

I'll be watching this thread like a hawk in the hopes that a solution is found.