You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Instruments中OSSignpost间隔无法记录显示问题求助

OSSignposter集成大型应用后无法记录时间间隔问题

问题描述

尝试使用OSSignposter捕获应用中的时间间隔,用于Instruments分析。示例代码在新项目中可正常显示间隔与标记图标,但集成到大型应用后完全无法记录或显示任何间隔。

已做排查

  • 核对两个应用的oslog配置状态,无差异:
    sudo log config --status --subsystem **.*******.*******.signposttest
    Mode for '**.*******.*******.signposttest'  INFO PERSIST_DEFAULT
    
  • 确认工作区与Scheme设置无区别;
  • 排查构建设置,未设置OS_ACTIVITY_MODE = disable,尝试调试配置文件无效;
  • 不同模式下的异常表现:
    • immediate mode和deferred mode:无标记活动,仅在「List: Events」视图底部面板可见事件;
    • last n seconds mode:时间线无数据、无lanes。

示例代码(双项目测试验证)

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

效果对比

  • 正常效果:正常显示的Signpost
  • 问题项目效果:无数据的Signpost

补充更新

通过代码检测发现signposter.isEnabled始终为false,未显式禁用OSSignposter,且无法通过代码手动启用:

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

该断言始终触发。


内容的提问来源于stack exchange,提问作者Byron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 08:21:57