Skip to content

Commit 5d3d398

Browse files
zhigang1992facebook-github-bot
authored andcommitted
- fix crash on performance logger (#24821)
Summary: Fix Issue #24820 It's caused by `_labelsForTags` and `RCTPLTag` being out of sync, the crash might only be one of the issues that this bug was causing. ## Changelog [iOS] [Fixed] - fix crash on performance logger Pull Request resolved: #24821 Differential Revision: D15407291 Pulled By: PeteTheHeat fbshipit-source-id: c8d2a047fceb9cec981c48fe5181d1b4cbf0976c
1 parent 64db98f commit 5d3d398

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

RNTester/RNTester.xcodeproj/project.pbxproj

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */; };
11+
04F27E112288190500F536C3 /* RCTPerformanceLoggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */; };
1112
1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1300627E1B59179B0043FE5A /* RCTGzipTests.m */; };
1213
13129DD41C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */; };
1314
13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; };
@@ -479,6 +480,7 @@
479480
/* Begin PBXFileReference section */
480481
001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMultipartStreamReaderTests.m; sourceTree = "<group>"; };
481482
004D289E1AAF61C70097A701 /* RNTesterUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNTesterUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
483+
04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTPerformanceLoggerTests.m; sourceTree = "<group>"; };
482484
1300627E1B59179B0043FE5A /* RCTGzipTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTGzipTests.m; sourceTree = "<group>"; };
483485
13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTModuleInitNotificationRaceTests.m; sourceTree = "<group>"; };
484486
13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
@@ -813,6 +815,7 @@
813815
BC9C033F1DC9F1D600B1C635 /* RCTDevMenuTests.m */,
814816
13BCE84E1C9C209600DD7AAD /* RCTComponentPropsTests.m */,
815817
39AA31A31DC1DFDC000F7EBB /* RCTUnicodeDecodeTests.m */,
818+
04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */,
816819
143BC57E1B21E18100462512 /* Info.plist */,
817820
3DD981D51D33C6FB007DC7BE /* RNTesterUnitTestsBundle.js */,
818821
14D6D7101B220EB3001FB087 /* libOCMock.a */,
@@ -1740,6 +1743,7 @@
17401743
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */,
17411744
13DB03481B5D2ED500C27245 /* RCTJSONTests.m in Sources */,
17421745
1497CFAC1B21F5E400C1F8F2 /* RCTAllocationTests.m in Sources */,
1746+
04F27E112288190500F536C3 /* RCTPerformanceLoggerTests.m in Sources */,
17431747
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */,
17441748
13DF61B61B67A45000EDB188 /* RCTMethodArgumentTests.m in Sources */,
17451749
138D6A181B53CD440074A87E /* RCTShadowViewTests.m in Sources */,
@@ -1914,10 +1918,10 @@
19141918
BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js";
19151919
DEVELOPMENT_TEAM = VYK7DLU38Z;
19161920
GCC_PREPROCESSOR_DEFINITIONS = (
1917-
"RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)",
1918-
"DEBUG=1",
1919-
"$(inherited)",
1920-
);
1921+
"RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)",
1922+
"DEBUG=1",
1923+
"$(inherited)",
1924+
);
19211925
HEADER_SEARCH_PATHS = (
19221926
"$(SRCROOT)/../third-party/boost_1_63_0",
19231927
"$(SRCROOT)/../third-party/folly-2018.10.22.00",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
#import <React/RCTPerformanceLogger.h>
10+
11+
#import <XCTest/XCTest.h>
12+
13+
@interface RCTPerformanceLoggerTests : XCTestCase
14+
15+
@end
16+
17+
@implementation RCTPerformanceLoggerTests
18+
19+
- (void)testLabelCountInSyncWithRCTPLTag
20+
{
21+
RCTPerformanceLogger *logger = [[RCTPerformanceLogger alloc] init];
22+
XCTAssertEqual([logger labelsForTags].count, RCTPLSize);
23+
}
24+
25+
@end

React/Base/RCTPerformanceLogger.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#import <Foundation/Foundation.h>
99

10+
// Keep this in sync with _labelsForTags
1011
typedef NS_ENUM(NSUInteger, RCTPLTag) {
1112
RCTPLScriptDownload = 0,
1213
RCTPLScriptExecution,
@@ -26,7 +27,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
2627
RCTPLBridgeStartup,
2728
RCTPLTTI,
2829
RCTPLBundleSize,
29-
RCTPLSize
30+
RCTPLSize // This is used to count the size
3031
};
3132

3233
@interface RCTPerformanceLogger : NSObject

React/Base/RCTPerformanceLogger.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ @implementation RCTPerformanceLogger
2727
- (instancetype)init
2828
{
2929
if (self = [super init]) {
30+
// Keep this in sync with RCTPLTag
3031
_labelsForTags = @[
3132
@"ScriptDownload",
3233
@"ScriptExecution",
@@ -39,12 +40,10 @@ - (instancetype)init
3940
@"NativeModuleInit",
4041
@"NativeModuleMainThread",
4142
@"NativeModulePrepareConfig",
42-
@"NativeModuleInjectConfig",
4343
@"NativeModuleMainThreadUsesCount",
4444
@"NativeModuleSetup",
4545
@"TurboModuleSetup",
4646
@"JSCWrapperOpenLibrary",
47-
@"JSCExecutorSetup",
4847
@"BridgeStartup",
4948
@"RootViewTTI",
5049
@"BundleSize",

0 commit comments

Comments
 (0)