Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS][Bug] - fix crash on performance logger #24821

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions RNTester/RNTester.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */; };
04F27E112288190500F536C3 /* RCTPerformanceLoggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */; };
1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1300627E1B59179B0043FE5A /* RCTGzipTests.m */; };
13129DD41C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */; };
13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; };
Expand Down Expand Up @@ -479,6 +480,7 @@
/* Begin PBXFileReference section */
001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMultipartStreamReaderTests.m; sourceTree = "<group>"; };
004D289E1AAF61C70097A701 /* RNTesterUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNTesterUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTPerformanceLoggerTests.m; sourceTree = "<group>"; };
1300627E1B59179B0043FE5A /* RCTGzipTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTGzipTests.m; sourceTree = "<group>"; };
13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTModuleInitNotificationRaceTests.m; sourceTree = "<group>"; };
13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
Expand Down Expand Up @@ -813,6 +815,7 @@
BC9C033F1DC9F1D600B1C635 /* RCTDevMenuTests.m */,
13BCE84E1C9C209600DD7AAD /* RCTComponentPropsTests.m */,
39AA31A31DC1DFDC000F7EBB /* RCTUnicodeDecodeTests.m */,
04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */,
143BC57E1B21E18100462512 /* Info.plist */,
3DD981D51D33C6FB007DC7BE /* RNTesterUnitTestsBundle.js */,
14D6D7101B220EB3001FB087 /* libOCMock.a */,
Expand Down Expand Up @@ -1740,6 +1743,7 @@
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */,
13DB03481B5D2ED500C27245 /* RCTJSONTests.m in Sources */,
1497CFAC1B21F5E400C1F8F2 /* RCTAllocationTests.m in Sources */,
04F27E112288190500F536C3 /* RCTPerformanceLoggerTests.m in Sources */,
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */,
13DF61B61B67A45000EDB188 /* RCTMethodArgumentTests.m in Sources */,
138D6A181B53CD440074A87E /* RCTShadowViewTests.m in Sources */,
Expand Down Expand Up @@ -1914,10 +1918,10 @@
BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js";
DEVELOPMENT_TEAM = VYK7DLU38Z;
GCC_PREPROCESSOR_DEFINITIONS = (
"RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)",
"DEBUG=1",
"$(inherited)",
);
"RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)",
"DEBUG=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../third-party/boost_1_63_0",
"$(SRCROOT)/../third-party/folly-2018.10.22.00",
Expand Down
25 changes: 25 additions & 0 deletions RNTester/RNTesterUnitTests/RCTPerformanceLoggerTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

#import <React/RCTPerformanceLogger.h>

#import <XCTest/XCTest.h>

@interface RCTPerformanceLoggerTests : XCTestCase

@end

@implementation RCTPerformanceLoggerTests

- (void)testLabelCountInSyncWithRCTPLTag
{
RCTPerformanceLogger *logger = [[RCTPerformanceLogger alloc] init];
XCTAssertEqual([logger labelsForTags].count, RCTPLSize);
}

@end
3 changes: 2 additions & 1 deletion React/Base/RCTPerformanceLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import <Foundation/Foundation.h>

// Keep this in sync with _labelsForTags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd better to remove these missing labels in _labelForTags? because we don't use these enums at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, +1

typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLScriptDownload = 0,
RCTPLScriptExecution,
Expand All @@ -26,7 +27,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLBridgeStartup,
RCTPLTTI,
RCTPLBundleSize,
RCTPLSize
RCTPLSize // This is used to count the size
};

@interface RCTPerformanceLogger : NSObject
Expand Down
3 changes: 1 addition & 2 deletions React/Base/RCTPerformanceLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ @implementation RCTPerformanceLogger
- (instancetype)init
{
if (self = [super init]) {
// Keep this in sync with RCTPLTag
_labelsForTags = @[
@"ScriptDownload",
@"ScriptExecution",
Expand All @@ -39,12 +40,10 @@ - (instancetype)init
@"NativeModuleInit",
@"NativeModuleMainThread",
@"NativeModulePrepareConfig",
@"NativeModuleInjectConfig",
@"NativeModuleMainThreadUsesCount",
@"NativeModuleSetup",
@"TurboModuleSetup",
@"JSCWrapperOpenLibrary",
@"JSCExecutorSetup",
@"BridgeStartup",
@"RootViewTTI",
@"BundleSize",
Expand Down