0

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).

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")
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
}

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

working signpost

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

enter image description here


Update

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: category)
assert(signposter.isEnabled)

This always asserts.

Byron
  • 1,091
  • 11
  • 27

1 Answers1

1

enter image description here

Try heading into your Scheme and adding this environment variable. This should fix the assert issue and hopefully also create some traces in Instruments.

Jeremy J
  • 56
  • 3