- fix crash on performance logger (#24821)

Summary:
Fix Issue https://github.com/facebook/react-native/issues/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: https://github.com/facebook/react-native/pull/24821

Differential Revision: D15407291

Pulled By: PeteTheHeat

fbshipit-source-id: c8d2a047fceb9cec981c48fe5181d1b4cbf0976c
This commit is contained in:
Kyle Fang 2019-05-18 08:23:37 -07:00 коммит произвёл Facebook Github Bot
Родитель 64db98febf
Коммит 5d3d3987d8
4 изменённых файлов: 36 добавлений и 7 удалений

Просмотреть файл

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */; }; 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 */; }; 1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1300627E1B59179B0043FE5A /* RCTGzipTests.m */; };
13129DD41C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */; }; 13129DD41C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 13129DD31C85F87C007D611C /* RCTModuleInitNotificationRaceTests.m */; };
13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; }; 13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; };
@ -479,6 +480,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
001BFCE31D838343008E587E /* RCTMultipartStreamReaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMultipartStreamReaderTests.m; sourceTree = "<group>"; }; 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; }; 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>"; }; 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>"; }; 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>"; }; 13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
@ -813,6 +815,7 @@
BC9C033F1DC9F1D600B1C635 /* RCTDevMenuTests.m */, BC9C033F1DC9F1D600B1C635 /* RCTDevMenuTests.m */,
13BCE84E1C9C209600DD7AAD /* RCTComponentPropsTests.m */, 13BCE84E1C9C209600DD7AAD /* RCTComponentPropsTests.m */,
39AA31A31DC1DFDC000F7EBB /* RCTUnicodeDecodeTests.m */, 39AA31A31DC1DFDC000F7EBB /* RCTUnicodeDecodeTests.m */,
04F27E102288190500F536C3 /* RCTPerformanceLoggerTests.m */,
143BC57E1B21E18100462512 /* Info.plist */, 143BC57E1B21E18100462512 /* Info.plist */,
3DD981D51D33C6FB007DC7BE /* RNTesterUnitTestsBundle.js */, 3DD981D51D33C6FB007DC7BE /* RNTesterUnitTestsBundle.js */,
14D6D7101B220EB3001FB087 /* libOCMock.a */, 14D6D7101B220EB3001FB087 /* libOCMock.a */,
@ -1740,6 +1743,7 @@
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */, 1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */,
13DB03481B5D2ED500C27245 /* RCTJSONTests.m in Sources */, 13DB03481B5D2ED500C27245 /* RCTJSONTests.m in Sources */,
1497CFAC1B21F5E400C1F8F2 /* RCTAllocationTests.m in Sources */, 1497CFAC1B21F5E400C1F8F2 /* RCTAllocationTests.m in Sources */,
04F27E112288190500F536C3 /* RCTPerformanceLoggerTests.m in Sources */,
001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */, 001BFCE41D838343008E587E /* RCTMultipartStreamReaderTests.m in Sources */,
13DF61B61B67A45000EDB188 /* RCTMethodArgumentTests.m in Sources */, 13DF61B61B67A45000EDB188 /* RCTMethodArgumentTests.m in Sources */,
138D6A181B53CD440074A87E /* RCTShadowViewTests.m in Sources */, 138D6A181B53CD440074A87E /* RCTShadowViewTests.m in Sources */,
@ -1914,10 +1918,10 @@
BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js"; BUNDLE_CONFIG = "$(SRCROOT)/../metro.config.js";
DEVELOPMENT_TEAM = VYK7DLU38Z; DEVELOPMENT_TEAM = VYK7DLU38Z;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)", "RN_BUNDLE_PREFIX=$(RN_BUNDLE_PREFIX)",
"DEBUG=1", "DEBUG=1",
"$(inherited)", "$(inherited)",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../third-party/boost_1_63_0", "$(SRCROOT)/../third-party/boost_1_63_0",
"$(SRCROOT)/../third-party/folly-2018.10.22.00", "$(SRCROOT)/../third-party/folly-2018.10.22.00",

Просмотреть файл

@ -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

Просмотреть файл

@ -7,6 +7,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// Keep this in sync with _labelsForTags
typedef NS_ENUM(NSUInteger, RCTPLTag) { typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLScriptDownload = 0, RCTPLScriptDownload = 0,
RCTPLScriptExecution, RCTPLScriptExecution,
@ -26,7 +27,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLBridgeStartup, RCTPLBridgeStartup,
RCTPLTTI, RCTPLTTI,
RCTPLBundleSize, RCTPLBundleSize,
RCTPLSize RCTPLSize // This is used to count the size
}; };
@interface RCTPerformanceLogger : NSObject @interface RCTPerformanceLogger : NSObject

Просмотреть файл

@ -27,6 +27,7 @@
- (instancetype)init - (instancetype)init
{ {
if (self = [super init]) { if (self = [super init]) {
// Keep this in sync with RCTPLTag
_labelsForTags = @[ _labelsForTags = @[
@"ScriptDownload", @"ScriptDownload",
@"ScriptExecution", @"ScriptExecution",
@ -39,12 +40,10 @@
@"NativeModuleInit", @"NativeModuleInit",
@"NativeModuleMainThread", @"NativeModuleMainThread",
@"NativeModulePrepareConfig", @"NativeModulePrepareConfig",
@"NativeModuleInjectConfig",
@"NativeModuleMainThreadUsesCount", @"NativeModuleMainThreadUsesCount",
@"NativeModuleSetup", @"NativeModuleSetup",
@"TurboModuleSetup", @"TurboModuleSetup",
@"JSCWrapperOpenLibrary", @"JSCWrapperOpenLibrary",
@"JSCExecutorSetup",
@"BridgeStartup", @"BridgeStartup",
@"RootViewTTI", @"RootViewTTI",
@"BundleSize", @"BundleSize",