如何解决Firebase Performance自定义跟踪启动/停止问题
我想测量屏幕上的加载时间,这涉及多个API调用,因此除了HTTP跟踪之外还需要自定义跟踪。屏幕上有一个页面的recyclerview,所以我需要多次运行跟踪。但是,这不起作用。我收到类似的错误
当我第二次尝试运行Trace 'Home_Loading' has already started,should not start again!
时,即使在调用stop()之后也是如此。例如,这段代码
val startupTrace = FirebasePerformance.getInstance().newTrace("Home_Loading")
startupTrace.start()
startupTrace.stop()
startupTrace.start()
startupTrace.stop()
产生以下日志
E/FirebasePerformance: Trace 'Home_Loading' has already started,should not start again!
E/FirebasePerformance: Trace 'Home_Loading' has already stopped,should not stop again!
D/FirebasePerformance: Logging trace metric - Home_Loading 0.0220ms
启动/停止方法是否不同步?还是不可能一次运行同一条跟踪?
解决方法
您不能多次启动和停止跟踪。一条轨迹只能有一个不同的起点和终点。如果需要执行第二次跟踪,则需要创建一个新的跟踪对象来启动和停止。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。