diff --git a/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.h b/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.h index 83a0aee3076de..7e94a8a2abc5d 100644 --- a/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.h +++ b/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.h @@ -29,3 +29,6 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +void CMPOSInitializeAppTraceLogger(NSString * _Nonnull name); +CMPOSLogger * _Nullable CMPOSAppTraceLogger(void); diff --git a/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.m b/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.m index 28c9dba90a888..19fd40777d190 100644 --- a/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.m +++ b/compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPOSLogger.m @@ -69,3 +69,13 @@ - (void)endInterval:(CMPOSLoggerInterval *)interval { @end + +static CMPOSLogger *_globalAppTraceLogger = nil; + +void CMPOSInitializeAppTraceLogger(NSString *name) { + _globalAppTraceLogger = [[CMPOSLogger alloc] initWithCategoryName:name]; +} + +CMPOSLogger * _Nullable CMPOSAppTraceLogger(void) { + return _globalAppTraceLogger; +} diff --git a/compose/ui/ui-util/src/uikitMain/kotlin/androidx/compose/ui/util/Trace.uikit.kt b/compose/ui/ui-util/src/uikitMain/kotlin/androidx/compose/ui/util/Trace.uikit.kt index 68ea4102ed996..0a9b7a3a97219 100644 --- a/compose/ui/ui-util/src/uikitMain/kotlin/androidx/compose/ui/util/Trace.uikit.kt +++ b/compose/ui/ui-util/src/uikitMain/kotlin/androidx/compose/ui/util/Trace.uikit.kt @@ -16,43 +16,26 @@ package androidx.compose.ui.util -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.InternalComposeUiApi -import androidx.compose.ui.uikit.utils.CMPOSLogger +import androidx.compose.ui.uikit.utils.CMPOSAppTraceLogger +import androidx.compose.ui.uikit.utils.CMPOSInitializeAppTraceLogger /** * Enables iOS OS logging for the `androidx.compose.ui` APIs. * * Tracing allows logging detailed information about the Compose UI framework, which can be further * analyzed using the XCode Instruments tool. - * - * This method is an [ExperimentalComposeUiApi], which means it is subject to change without notice in major, minor, or patch releases. - * - * @see ExperimentalComposeUiApi */ -@OptIn(InternalComposeUiApi::class) -@ExperimentalComposeUiApi fun enableTraceOSLog() { - if (traceImpl == null) { - traceImpl = CMPOSLogger(categoryName = "androidx.compose.ui") - } + CMPOSInitializeAppTraceLogger(name = "androidx.compose.ui") } -/** - * Instance of the [CMPOSLogger] used for tracing. Public due to `inline` requirement of [trace]. - * Intended for internal use only. - */ -@InternalComposeUiApi -var traceImpl: CMPOSLogger? = null - -@OptIn(InternalComposeUiApi::class) actual inline fun trace(sectionName: String, block: () -> T): T { - val interval = traceImpl?.beginIntervalNamed(sectionName) + val interval = CMPOSAppTraceLogger()?.beginIntervalNamed(sectionName) try { return block() } finally { interval?.let { - traceImpl?.endInterval(it) + CMPOSAppTraceLogger()?.endInterval(it) } } -} \ No newline at end of file +}