Skip to content

Commit

Permalink
Revert "[ReactNative] Track bridge events' flow"
Browse files Browse the repository at this point in the history
  • Loading branch information
Chace Liang committed Jun 2, 2015
1 parent 9b455c8 commit 4d4f2df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 83 deletions.
42 changes: 11 additions & 31 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -1339,29 +1339,22 @@ - (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arg
* AnyThread
*/

RCTProfileBeginFlowEvent();

__weak RCTBatchedBridge *weakSelf = self;
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
RCTProfileEndFlowEvent();
RCTProfileBeginEvent();

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


RCT_IF_DEV(NSNumber *callID = _RCTProfileBeginFlowEvent();)
id call = @{
@"js_args": @{
@"module": module,
@"method": method,
@"args": args,
},
@"module": module,
@"method": method,
@"args": args,
@"context": context ?: @0,
RCT_IF_DEV(@"call_id": callID,)
};

if ([method isEqualToString:@"invokeCallbackAndReturnFlushedQueue"]) {
strongSelf->_scheduledCallbacks[args[0]] = call;
} else {
Expand Down Expand Up @@ -1497,10 +1490,8 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i
return NO;
}

RCTProfileBeginFlowEvent();
__weak RCTBatchedBridge *weakSelf = self;
[self dispatchBlock:^{
RCTProfileEndFlowEvent();
RCTProfileBeginEvent();
RCTBatchedBridge *strongSelf = weakSelf;

Expand Down Expand Up @@ -1535,41 +1526,30 @@ - (void)_jsThreadUpdate:(CADisplayLink *)displayLink
{
RCTAssertJSThread();

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

RCT_IF_DEV(
RCTProfileImmediateEvent(@"JS Thread Tick", displayLink.timestamp, @"g");

for (NSDictionary *call in calls) {
_RCTProfileEndFlowEvent(call[@"call_id"]);
}
)
RCTProfileBeginEvent();

RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink];
for (id<RCTFrameUpdateObserver> observer in _frameUpdateObservers) {
if (![observer respondsToSelector:@selector(isPaused)] || ![observer isPaused]) {
RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];)
RCTProfileBeginFlowEvent();
[self dispatchBlock:^{
RCTProfileEndFlowEvent();
RCTProfileBeginEvent();
[observer didUpdateFrame:frameUpdate];
RCTProfileEndEvent(name, @"objc_call,fps", nil);
} forModule:RCTModuleIDsByName[RCTBridgeModuleNameForClass([observer class])]];
}
}

NSArray *calls = [_scheduledCallbacks.allObjects arrayByAddingObjectsFromArray:_scheduledCalls];
NSNumber *currentExecutorID = RCTGetExecutorID(_javaScriptExecutor);
calls = [calls filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSDictionary *call, NSDictionary *bindings) {
return [call[@"context"] isEqualToNumber:currentExecutorID];
}]];
if (calls.count > 0) {
_scheduledCalls = [[NSMutableArray alloc] init];
_scheduledCallbacks = [[RCTSparseArray alloc] init];
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
method:@"processBatch"
arguments:@[[calls valueForKey:@"js_args"]]
arguments:@[calls]
context:RCTGetExecutorID(_javaScriptExecutor)];
}

Expand Down
6 changes: 0 additions & 6 deletions React/Base/RCTDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
#endif
#endif

#if RCT_DEV
#define RCT_IF_DEV(...) __VA_ARGS__
#else
#define RCT_IF_DEV(...)
#endif

/**
* By default, only raise an NSAssertion in debug mode
* (custom assert functions will still be called).
Expand Down
18 changes: 0 additions & 18 deletions React/Base/RCTProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ NSString *const RCTProfileDidEndProfiling;

#if RCT_DEV

#define RCTProfileBeginFlowEvent() \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
NSNumber *__rct_profile_flow_id = _RCTProfileBeginFlowEvent(); \
_Pragma("clang diagnostic pop")

#define RCTProfileEndFlowEvent() \
_RCTProfileEndFlowEvent(__rct_profile_flow_id)

RCT_EXTERN NSNumber *_RCTProfileBeginFlowEvent(void);
RCT_EXTERN void _RCTProfileEndFlowEvent(NSNumber *);

/**
* Returns YES if the profiling information is currently being collected
*/
Expand Down Expand Up @@ -103,12 +91,6 @@ RCT_EXTERN void RCTProfileImmediateEvent(NSString *, NSTimeInterval , NSString *

#else

#define RCTProfileBeginFlowEvent()
#define _RCTProfileBeginFlowEvent() @0

#define RCTProfileEndFlowEvent()
#define _RCTProfileEndFlowEvent()

#define RCTProfileIsProfiling(...) NO
#define RCTProfileInit(...)
#define RCTProfileEnd(...) @""
Expand Down
28 changes: 0 additions & 28 deletions React/Base/RCTProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,4 @@ void RCTProfileImmediateEvent(NSString *name, NSTimeInterval timestamp, NSString
);
}

NSNumber *_RCTProfileBeginFlowEvent(void)
{
static NSUInteger flowID = 0;

CHECK(@0);
RCTProfileAddEvent(RCTProfileTraceEvents,
@"name": @"flow",
@"id": @(++flowID),
@"cat": @"flow",
@"ph": @"s",
@"ts": RCTProfileTimestamp(CACurrentMediaTime()),
);

return @(flowID);
}

void _RCTProfileEndFlowEvent(NSNumber *flowID)
{
CHECK();
RCTProfileAddEvent(RCTProfileTraceEvents,
@"name": @"flow",
@"id": flowID,
@"cat": @"flow",
@"ph": @"f",
@"ts": RCTProfileTimestamp(CACurrentMediaTime()),
);
}

#endif

0 comments on commit 4d4f2df

Please sign in to comment.