mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Make JS async always the top thread in systrace
Reviewed By: tadeuzagallo Differential Revision: D2905828 fb-gh-sync-id: b64cbe6b41771dc94d8d7e6d3610af845b4383f0 shipit-source-id: b64cbe6b41771dc94d8d7e6d3610af845b4383f0
This commit is contained in:
parent
8f363a3f5f
commit
84f51da123
@ -11,6 +11,11 @@
|
||||
|
||||
#import "RCTJavaScriptExecutor.h"
|
||||
|
||||
/**
|
||||
* Default name for the JS thread
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTJSCThreadName;
|
||||
|
||||
/**
|
||||
* Uses a JavaScriptCore context as the execution engine.
|
||||
*/
|
||||
|
@ -26,6 +26,8 @@
|
||||
#import "RCTRedBox.h"
|
||||
#import "RCTSourceCode.h"
|
||||
|
||||
NSString *const RCTJSCThreadName = @"com.facebook.React.JavaScript";
|
||||
|
||||
static NSString *const RCTJSCProfilerEnabledDefaultsKey = @"RCTJSCProfilerEnabled";
|
||||
|
||||
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
||||
@ -172,7 +174,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
||||
NSThread *javaScriptThread = [[NSThread alloc] initWithTarget:[self class]
|
||||
selector:@selector(runRunLoopThread)
|
||||
object:nil];
|
||||
javaScriptThread.name = @"com.facebook.React.JavaScript";
|
||||
javaScriptThread.name = RCTJSCThreadName;
|
||||
|
||||
if ([javaScriptThread respondsToSelector:@selector(setQualityOfService:)]) {
|
||||
[javaScriptThread setQualityOfService:NSOperationQualityOfServiceUserInteractive];
|
||||
|
@ -27,6 +27,7 @@
|
||||
#import "RCTModuleData.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTJSCExecutor.h"
|
||||
|
||||
NSString *const RCTProfileDidStartProfiling = @"RCTProfileDidStartProfiling";
|
||||
NSString *const RCTProfileDidEndProfiling = @"RCTProfileDidEndProfiling";
|
||||
@ -372,7 +373,6 @@ BOOL RCTProfileIsProfiling(void)
|
||||
void RCTProfileInit(RCTBridge *bridge)
|
||||
{
|
||||
// TODO: enable assert JS thread from any file (and assert here)
|
||||
|
||||
if (RCTProfileIsProfiling()) {
|
||||
return;
|
||||
}
|
||||
@ -395,6 +395,20 @@ void RCTProfileInit(RCTBridge *bridge)
|
||||
});
|
||||
}
|
||||
|
||||
// Set up thread ordering
|
||||
dispatch_async(RCTProfileGetQueue(), ^{
|
||||
NSString *shadowQueue = @(dispatch_queue_get_label([[bridge uiManager] methodQueue]));
|
||||
NSArray *orderedThreads = @[@"JS async", RCTJSCThreadName, shadowQueue, @"main"];
|
||||
[orderedThreads enumerateObjectsUsingBlock:^(NSString *thread, NSUInteger idx, BOOL *stop) {
|
||||
RCTProfileAddEvent(RCTProfileTraceEvents,
|
||||
@"ph": @"M", // metadata event
|
||||
@"name": @"thread_sort_index",
|
||||
@"tid": thread,
|
||||
@"args": @{ @"sort_index": @(-1000 + (NSInteger)idx) }
|
||||
);
|
||||
}];
|
||||
});
|
||||
|
||||
RCTProfileHookModules(bridge);
|
||||
|
||||
RCTProfileDisplayLink = [CADisplayLink displayLinkWithTarget:[RCTProfile class]
|
||||
|
Loading…
x
Reference in New Issue
Block a user