Skip to content

Commit c047b59

Browse files
authored
[Darwin] Remove StartupMetricsCollection from fw init (project-chip#32744)
- MTRFrameworkInit was initializing metrics collector but if controller factory is never created tracing backend will crash on system exit. - Remove the unbalanced init and rely on controller to register and unregister the backend - Added more logging on shutdown
1 parent 6a939e9 commit c047b59

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+8-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@
8484
static NSString * const kErrorSessionKeystoreInit = @"Init failure while initializing session keystore";
8585

8686
static bool sExitHandlerRegistered = false;
87-
static void ShutdownOnExit() { [[MTRDeviceControllerFactory sharedInstance] stopControllerFactory]; }
87+
static void ShutdownOnExit()
88+
{
89+
MTR_LOG_INFO("ShutdownOnExit invoked on exit");
90+
[[MTRDeviceControllerFactory sharedInstance] stopControllerFactory];
91+
}
8892

8993
@interface MTRDeviceControllerFactory () {
9094
MTRServerEndpoint * _otaProviderEndpoint;
@@ -323,6 +327,8 @@ - (void)cleanupInitObjects
323327

324328
- (void)cleanupStartupObjects
325329
{
330+
MTR_LOG_INFO("Cleaning startup objects in controller factory");
331+
326332
// Make sure the deinit order here is the reverse of the init order in
327333
// startControllerFactory:
328334
_certificationDeclarationCertificates = nil;
@@ -562,7 +568,7 @@ - (void)stopControllerFactory
562568
[_controllers[0] shutdown];
563569
}
564570

565-
MTR_LOG_DEBUG("Shutting down the Matter controller factory");
571+
MTR_LOG_INFO("Shutting down the Matter controller factory");
566572
_controllerFactory->Shutdown();
567573

568574
[self cleanupStartupObjects];

src/darwin/Framework/CHIP/MTRFramework.mm

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
#import "MTRFramework.h"
18-
#import "MTRMetricsCollector.h"
1918

2019
#include <dispatch/dispatch.h>
2120
#include <lib/support/CHIPMem.h>
@@ -35,8 +34,5 @@ void MTRFrameworkInit()
3534
// Suppress CHIP logging until we actually need it for redirection
3635
// (see MTRSetLogCallback()). Logging to os_log is always enabled.
3736
chip::Logging::SetLogFilter(chip::Logging::kLogCategory_None);
38-
39-
// Startup metrics collection and tracing framework
40-
StartupMetricsCollection();
4137
});
4238
}

0 commit comments

Comments
 (0)