Skip to content

Commit 4d4f2df

Browse files
author
Chace Liang
committed
Revert "[ReactNative] Track bridge events' flow"
1 parent 9b455c8 commit 4d4f2df

File tree

4 files changed

+11
-83
lines changed

4 files changed

+11
-83
lines changed

React/Base/RCTBridge.m

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,29 +1339,22 @@ - (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arg
13391339
* AnyThread
13401340
*/
13411341

1342-
RCTProfileBeginFlowEvent();
1343-
13441342
__weak RCTBatchedBridge *weakSelf = self;
13451343
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
1346-
RCTProfileEndFlowEvent();
13471344
RCTProfileBeginEvent();
13481345

13491346
RCTBatchedBridge *strongSelf = weakSelf;
13501347
if (!strongSelf.isValid || !strongSelf->_scheduledCallbacks || !strongSelf->_scheduledCalls) {
13511348
return;
13521349
}
13531350

1354-
1355-
RCT_IF_DEV(NSNumber *callID = _RCTProfileBeginFlowEvent();)
13561351
id call = @{
1357-
@"js_args": @{
1358-
@"module": module,
1359-
@"method": method,
1360-
@"args": args,
1361-
},
1352+
@"module": module,
1353+
@"method": method,
1354+
@"args": args,
13621355
@"context": context ?: @0,
1363-
RCT_IF_DEV(@"call_id": callID,)
13641356
};
1357+
13651358
if ([method isEqualToString:@"invokeCallbackAndReturnFlushedQueue"]) {
13661359
strongSelf->_scheduledCallbacks[args[0]] = call;
13671360
} else {
@@ -1497,10 +1490,8 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i
14971490
return NO;
14981491
}
14991492

1500-
RCTProfileBeginFlowEvent();
15011493
__weak RCTBatchedBridge *weakSelf = self;
15021494
[self dispatchBlock:^{
1503-
RCTProfileEndFlowEvent();
15041495
RCTProfileBeginEvent();
15051496
RCTBatchedBridge *strongSelf = weakSelf;
15061497

@@ -1535,41 +1526,30 @@ - (void)_jsThreadUpdate:(CADisplayLink *)displayLink
15351526
{
15361527
RCTAssertJSThread();
15371528

1538-
NSArray *calls = [_scheduledCallbacks.allObjects arrayByAddingObjectsFromArray:_scheduledCalls];
1539-
NSNumber *currentExecutorID = RCTGetExecutorID(_javaScriptExecutor);
1540-
calls = [calls filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSDictionary *call, NSDictionary *bindings) {
1541-
return [call[@"context"] isEqualToNumber:currentExecutorID];
1542-
}]];
1529+
RCTProfileImmediateEvent(@"JS Thread Tick", displayLink.timestamp, @"g");
15431530

1544-
RCT_IF_DEV(
1545-
RCTProfileImmediateEvent(@"JS Thread Tick", displayLink.timestamp, @"g");
1546-
1547-
for (NSDictionary *call in calls) {
1548-
_RCTProfileEndFlowEvent(call[@"call_id"]);
1549-
}
1550-
)
15511531
RCTProfileBeginEvent();
15521532

15531533
RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink];
15541534
for (id<RCTFrameUpdateObserver> observer in _frameUpdateObservers) {
15551535
if (![observer respondsToSelector:@selector(isPaused)] || ![observer isPaused]) {
1556-
RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];)
1557-
RCTProfileBeginFlowEvent();
15581536
[self dispatchBlock:^{
1559-
RCTProfileEndFlowEvent();
1560-
RCTProfileBeginEvent();
15611537
[observer didUpdateFrame:frameUpdate];
1562-
RCTProfileEndEvent(name, @"objc_call,fps", nil);
15631538
} forModule:RCTModuleIDsByName[RCTBridgeModuleNameForClass([observer class])]];
15641539
}
15651540
}
15661541

1542+
NSArray *calls = [_scheduledCallbacks.allObjects arrayByAddingObjectsFromArray:_scheduledCalls];
1543+
NSNumber *currentExecutorID = RCTGetExecutorID(_javaScriptExecutor);
1544+
calls = [calls filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSDictionary *call, NSDictionary *bindings) {
1545+
return [call[@"context"] isEqualToNumber:currentExecutorID];
1546+
}]];
15671547
if (calls.count > 0) {
15681548
_scheduledCalls = [[NSMutableArray alloc] init];
15691549
_scheduledCallbacks = [[RCTSparseArray alloc] init];
15701550
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
15711551
method:@"processBatch"
1572-
arguments:@[[calls valueForKey:@"js_args"]]
1552+
arguments:@[calls]
15731553
context:RCTGetExecutorID(_javaScriptExecutor)];
15741554
}
15751555

React/Base/RCTDefines.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@
4242
#endif
4343
#endif
4444

45-
#if RCT_DEV
46-
#define RCT_IF_DEV(...) __VA_ARGS__
47-
#else
48-
#define RCT_IF_DEV(...)
49-
#endif
50-
5145
/**
5246
* By default, only raise an NSAssertion in debug mode
5347
* (custom assert functions will still be called).

React/Base/RCTProfile.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ NSString *const RCTProfileDidEndProfiling;
2525

2626
#if RCT_DEV
2727

28-
#define RCTProfileBeginFlowEvent() \
29-
_Pragma("clang diagnostic push") \
30-
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
31-
NSNumber *__rct_profile_flow_id = _RCTProfileBeginFlowEvent(); \
32-
_Pragma("clang diagnostic pop")
33-
34-
#define RCTProfileEndFlowEvent() \
35-
_RCTProfileEndFlowEvent(__rct_profile_flow_id)
36-
37-
RCT_EXTERN NSNumber *_RCTProfileBeginFlowEvent(void);
38-
RCT_EXTERN void _RCTProfileEndFlowEvent(NSNumber *);
39-
4028
/**
4129
* Returns YES if the profiling information is currently being collected
4230
*/
@@ -103,12 +91,6 @@ RCT_EXTERN void RCTProfileImmediateEvent(NSString *, NSTimeInterval , NSString *
10391

10492
#else
10593

106-
#define RCTProfileBeginFlowEvent()
107-
#define _RCTProfileBeginFlowEvent() @0
108-
109-
#define RCTProfileEndFlowEvent()
110-
#define _RCTProfileEndFlowEvent()
111-
11294
#define RCTProfileIsProfiling(...) NO
11395
#define RCTProfileInit(...)
11496
#define RCTProfileEnd(...) @""

React/Base/RCTProfile.m

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -180,32 +180,4 @@ void RCTProfileImmediateEvent(NSString *name, NSTimeInterval timestamp, NSString
180180
);
181181
}
182182

183-
NSNumber *_RCTProfileBeginFlowEvent(void)
184-
{
185-
static NSUInteger flowID = 0;
186-
187-
CHECK(@0);
188-
RCTProfileAddEvent(RCTProfileTraceEvents,
189-
@"name": @"flow",
190-
@"id": @(++flowID),
191-
@"cat": @"flow",
192-
@"ph": @"s",
193-
@"ts": RCTProfileTimestamp(CACurrentMediaTime()),
194-
);
195-
196-
return @(flowID);
197-
}
198-
199-
void _RCTProfileEndFlowEvent(NSNumber *flowID)
200-
{
201-
CHECK();
202-
RCTProfileAddEvent(RCTProfileTraceEvents,
203-
@"name": @"flow",
204-
@"id": flowID,
205-
@"cat": @"flow",
206-
@"ph": @"f",
207-
@"ts": RCTProfileTimestamp(CACurrentMediaTime()),
208-
);
209-
}
210-
211183
#endif

0 commit comments

Comments
 (0)