Skip to content

Commit e3728eb

Browse files
Arsen GhazaryanJustin Spears
authored andcommitted
Add missing license to UnimplementedView.js
Summary: Added a missing license header to UnimplementedView.js No code logic got changed, just added a comment. So the regular CircleCI tests should be fine. Closes #13952 Differential Revision: D5056778 Pulled By: javache fbshipit-source-id: feb106946a9a34cfdf2df63de21305ac779296f4 Improve systrace markers Reviewed By: mhorowitz Differential Revision: D4860135 fbshipit-source-id: ce963010883e6b9cc8e34f7ff01b4018cd195eba
1 parent 5906136 commit e3728eb

File tree

17 files changed

+122
-93
lines changed

17 files changed

+122
-93
lines changed

Libraries/Components/UnimplementedViews/UnimplementedView.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
/**
2-
* Common implementation for a simple stubbed view. Simply applies the view's styles to the inner
3-
* View component and renders its children.
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
48
*
59
* @providesModule UnimplementedView
10+
* @flow
611
*/
7-
812
'use strict';
913

1014
var React = require('React');
1115
var StyleSheet = require('StyleSheet');
1216

17+
/**
18+
* Common implementation for a simple stubbed view. Simply applies the view's styles to the inner
19+
* View component and renders its children.
20+
*/
1321
class UnimplementedView extends React.Component {
1422
setNativeProps = () => {
1523
// Do nothing.

React/CxxBridge/RCTCxxBridge.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ @interface RCTCxxBridge : RCTBridge
5454
RCTAssert(self.executorClass || self->_jsThread == [NSThread currentThread], \
5555
@"This method must be called on JS thread")
5656

57-
NSString *const RCTJSThreadName = @"com.facebook.React.JavaScript";
57+
static NSString *const RCTJSThreadName = @"com.facebook.react.JavaScript";
5858

5959
using namespace facebook::react;
6060

@@ -76,7 +76,7 @@ static bool isRAMBundle(NSData *script) {
7676

7777
static void registerPerformanceLoggerHooks(RCTPerformanceLogger *performanceLogger) {
7878
__weak RCTPerformanceLogger *weakPerformanceLogger = performanceLogger;
79-
ReactMarker::logTaggedMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId, const char* tag) {
79+
ReactMarker::logTaggedMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId, const char *tag) {
8080
switch (markerId) {
8181
case ReactMarker::RUN_JS_BUNDLE_START:
8282
[weakPerformanceLogger markStartForTag:RCTPLScriptExecution];
@@ -255,6 +255,8 @@ - (void)executeBlockOnJavaScriptThread:(dispatch_block_t)block
255255

256256
- (void)start
257257
{
258+
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTCxxBridge start]", nil);
259+
258260
[[NSNotificationCenter defaultCenter]
259261
postNotificationName:RCTJavaScriptWillStartLoadingNotification
260262
object:_parentBridge userInfo:@{@"bridge": self}];
@@ -349,6 +351,7 @@ - (void)start
349351
}
350352
});
351353
}
354+
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
352355
}
353356

354357
- (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad onProgress:(RCTSourceLoadProgressBlock)onProgress
@@ -963,7 +966,7 @@ - (void)_flushPendingCalls
963966

964967
[_performanceLogger markStopForTag:RCTPLBridgeStartup];
965968

966-
RCT_PROFILE_BEGIN_EVENT(0, @"Processing pendingCalls", @{ @"count": @(_pendingCalls.count) });
969+
RCT_PROFILE_BEGIN_EVENT(0, @"Processing pendingCalls", @{ @"count": [@(_pendingCalls.count) stringValue] });
967970
// Phase B: _flushPendingCalls happens. Each block in _pendingCalls is
968971
// executed, adding work to the queue, and _pendingCount is decremented.
969972
// loading is set to NO.
@@ -1051,8 +1054,7 @@ - (void)enqueueApplicationScript:(NSData *)script
10511054
{
10521055
RCTAssert(onComplete != nil, @"onComplete block passed in should be non-nil");
10531056

1054-
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
1055-
@"-[RCTCxxBridge enqueueApplicationScript]", nil);
1057+
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTCxxBridge enqueueApplicationScript]", nil);
10561058

10571059
[self _tryAndHandleError:^{
10581060
if (isRAMBundle(script)) {

React/CxxModule/RCTNativeModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RCTNativeModule : public NativeModule {
2020
std::string getName() override;
2121
std::vector<MethodDescriptor> getMethods() override;
2222
folly::dynamic getConstants() override;
23-
void invoke(unsigned int methodId, folly::dynamic &&params) override;
23+
void invoke(unsigned int methodId, folly::dynamic &&params, int callId) override;
2424
MethodCallResult callSerializableNativeHook(unsigned int reactMethodId, folly::dynamic &&params) override;
2525

2626
private:

React/CxxModule/RCTNativeModule.mm

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#import <React/RCTProfile.h>
1818
#import <React/RCTUtils.h>
1919

20+
#ifdef WITH_FBSYSTRACE
21+
#include <fbsystrace.h>
22+
#endif
23+
2024
namespace facebook {
2125
namespace react {
2226

@@ -50,20 +54,20 @@
5054
return ret;
5155
}
5256

53-
void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &&params) {
57+
void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &&params, int callId) {
5458
// The BatchedBridge version of this buckets all the callbacks by thread, and
5559
// queues one block on each. This is much simpler; we'll see how it goes and
5660
// iterate.
57-
dispatch_block_t block = [this, methodId, params=std::move(params)] {
58-
if (!m_bridge.valid) {
59-
return;
61+
dispatch_block_t block = [this, methodId, params=std::move(params), callId] {
62+
#ifdef WITH_FBSYSTRACE
63+
if (callId != -1) {
64+
fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
6065
}
61-
66+
#endif
6267
invokeInner(methodId, std::move(params));
6368
};
6469

6570
dispatch_queue_t queue = m_moduleData.methodQueue;
66-
6771
if (queue == RCTJSThread) {
6872
block();
6973
} else if (queue) {
@@ -76,14 +80,17 @@
7680
}
7781

7882
MethodCallResult RCTNativeModule::invokeInner(unsigned int methodId, const folly::dynamic &&params) {
83+
if (!m_bridge.valid) {
84+
return folly::none;
85+
}
86+
7987
id<RCTBridgeMethod> method = m_moduleData.methods[methodId];
8088
if (RCT_DEBUG && !method) {
8189
RCTLogError(@"Unknown methodID: %ud for module: %@",
8290
methodId, m_moduleData.name);
8391
}
8492

8593
NSArray *objcParams = convertFollyDynamicToId(params);
86-
8794
@try {
8895
id result = [method invokeWithBridge:m_bridge module:m_moduleData.instance arguments:objcParams];
8996
return convertIdToFollyDynamic(result);
@@ -99,7 +106,6 @@
99106
exception, method.JSMethodName, m_moduleData.name, objcParams];
100107
RCTFatal(RCTErrorWithMessage(message));
101108
}
102-
103109
}
104110

105111
}

React/Modules/RCTUIManager.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#import "RCTRootViewInternal.h"
3333
#import "RCTScrollableProtocol.h"
3434
#import "RCTShadowView.h"
35-
#import "RCTUtils.h"
3635
#import "RCTUIManagerObserverCoordinator.h"
36+
#import "RCTUtils.h"
3737
#import "RCTView.h"
3838
#import "RCTViewManager.h"
3939
#import "UIView+React.h"
@@ -1192,7 +1192,7 @@ - (void)flushUIBlocks
11921192
dispatch_async(dispatch_get_main_queue(), ^{
11931193
RCTProfileEndFlowEvent();
11941194
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", (@{
1195-
@"count": @(previousPendingUIBlocks.count),
1195+
@"count": [@(previousPendingUIBlocks.count) stringValue],
11961196
}));
11971197
@try {
11981198
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
@@ -1202,6 +1202,7 @@ - (void)flushUIBlocks
12021202
@catch (NSException *exception) {
12031203
RCTLogError(@"Exception thrown while executing UI block: %@", exception);
12041204
}
1205+
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
12051206
});
12061207
}
12071208
}

React/Profiler/RCTProfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread,
6868
NSTimeInterval time,
6969
uint64_t tag,
7070
NSString *name,
71-
NSDictionary *args);
71+
NSDictionary<NSString *, NSString *> *args);
7272
#define RCT_PROFILE_BEGIN_EVENT(tag, name, args) \
7373
do { \
7474
if (RCTProfileIsProfiling()) { \
@@ -104,7 +104,7 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread,
104104
*/
105105
RCT_EXTERN NSUInteger RCTProfileBeginAsyncEvent(uint64_t tag,
106106
NSString *name,
107-
NSDictionary *args);
107+
NSDictionary<NSString *, NSString *> *args);
108108

109109
/**
110110
* The ID returned by BeginEvent should then be passed into EndEvent, with the

React/Profiler/RCTProfile.m

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,19 @@
7171
static RCTProfileCallbacks *callbacks;
7272
static char *systrace_buffer;
7373

74-
static systrace_arg_t *RCTProfileSystraceArgsFromNSDictionary(NSDictionary *args)
74+
static systrace_arg_t *systraceArgsFromDictionary(NSDictionary<NSString *, NSString *> *args)
7575
{
7676
if (args.count == 0) {
7777
return NULL;
7878
}
7979

8080
systrace_arg_t *systrace_args = malloc(sizeof(systrace_arg_t) * args.count);
8181
__block size_t i = 0;
82-
[args enumerateKeysAndObjectsUsingBlock:^(id key, id value, __unused BOOL *stop) {
83-
const char *keyc = [key description].UTF8String;
84-
systrace_args[i].key = keyc;
85-
systrace_args[i].key_len = (int)strlen(keyc);
86-
87-
const char *valuec = RCTJSONStringify(value, NULL).UTF8String;
88-
systrace_args[i].value = valuec;
89-
systrace_args[i].value_len = (int)strlen(valuec);
82+
[args enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) {
83+
systrace_args[i].key = [key UTF8String];
84+
systrace_args[i].key_len = [key length];
85+
systrace_args[i].value = [value UTF8String];
86+
systrace_args[i].value_len = [value length];
9087
i++;
9188
}];
9289
return systrace_args;
@@ -123,7 +120,7 @@ void RCTProfileRegisterCallbacks(RCTProfileCallbacks *cb)
123120
TASK_BASIC_INFO,
124121
(task_info_t)&info,
125122
&size);
126-
if( kerr == KERN_SUCCESS ) {
123+
if ( kerr == KERN_SUCCESS ) {
127124
return @{
128125
@"suspend_count": @(info.suspend_count),
129126
@"virtual_size": RCTProfileMemory(info.virtual_size),
@@ -545,12 +542,12 @@ void _RCTProfileBeginEvent(
545542
NSTimeInterval time,
546543
uint64_t tag,
547544
NSString *name,
548-
NSDictionary *args
545+
NSDictionary<NSString *, NSString *> *args
549546
) {
550547
CHECK();
551548

552549
if (callbacks != NULL) {
553-
callbacks->begin_section(tag, name.UTF8String, args.count, RCTProfileSystraceArgsFromNSDictionary(args));
550+
callbacks->begin_section(tag, name.UTF8String, args.count, systraceArgsFromDictionary(args));
554551
return;
555552
}
556553

@@ -603,7 +600,7 @@ void _RCTProfileEndEvent(
603600
NSUInteger RCTProfileBeginAsyncEvent(
604601
uint64_t tag,
605602
NSString *name,
606-
NSDictionary *args
603+
NSDictionary<NSString *, NSString *> *args
607604
) {
608605
CHECK(0);
609606

@@ -613,7 +610,8 @@ NSUInteger RCTProfileBeginAsyncEvent(
613610
NSUInteger currentEventID = ++eventID;
614611

615612
if (callbacks != NULL) {
616-
callbacks->begin_async_section(tag, name.UTF8String, (int)(currentEventID % INT_MAX), args.count, RCTProfileSystraceArgsFromNSDictionary(args));
613+
callbacks->begin_async_section(tag, name.UTF8String, (int)(currentEventID % INT_MAX),
614+
args.count, systraceArgsFromDictionary(args));
617615
} else {
618616
dispatch_async(RCTProfileGetQueue(), ^{
619617
RCTProfileOngoingEvents[@(currentEventID)] = @[

ReactAndroid/src/main/jni/xreact/jni/JavaModuleWrapper.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include <cxxreact/JsArgumentHelpers.h>
1111
#include <cxxreact/NativeModule.h>
1212

13+
#ifdef WITH_FBSYSTRACE
14+
#include <fbsystrace.h>
15+
#endif
16+
1317
#include "CatalystInstanceImpl.h"
1418
#include "ReadableNativeArray.h"
1519

@@ -80,9 +84,14 @@ folly::dynamic JavaNativeModule::getConstants() {
8084
}
8185
}
8286

83-
void JavaNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params) {
84-
messageQueueThread_->runOnQueue([this, reactMethodId, params=std::move(params)] {
87+
void JavaNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) {
88+
messageQueueThread_->runOnQueue([this, reactMethodId, params=std::move(params), callId] {
8589
static auto invokeMethod = wrapper_->getClass()->getMethod<void(jint, ReadableNativeArray::javaobject)>("invoke");
90+
#ifdef WITH_FBSYSTRACE
91+
if (callId != -1) {
92+
fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
93+
}
94+
#endif
8695
invokeMethod(
8796
wrapper_,
8897
static_cast<jint>(reactMethodId),
@@ -148,13 +157,18 @@ folly::dynamic NewJavaNativeModule::getConstants() {
148157
}
149158
}
150159

151-
void NewJavaNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params) {
160+
void NewJavaNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) {
152161
if (reactMethodId >= methods_.size()) {
153162
throw std::invalid_argument(
154163
folly::to<std::string>("methodId ", reactMethodId, " out of range [0..", methods_.size(), "]"));
155164
}
156165
CHECK(!methods_[reactMethodId].isSyncHook()) << "Trying to invoke a synchronous hook asynchronously";
157-
messageQueueThread_->runOnQueue([this, reactMethodId, params=std::move(params)] () mutable {
166+
messageQueueThread_->runOnQueue([this, reactMethodId, params=std::move(params), callId] () mutable {
167+
#ifdef WITH_FBSYSTRACE
168+
if (callId != -1) {
169+
fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
170+
}
171+
#endif
158172
invokeInner(reactMethodId, std::move(params));
159173
});
160174
}

ReactAndroid/src/main/jni/xreact/jni/JavaModuleWrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class JavaNativeModule : public NativeModule {
5959
std::string getName() override;
6060
folly::dynamic getConstants() override;
6161
std::vector<MethodDescriptor> getMethods() override;
62-
void invoke(unsigned int reactMethodId, folly::dynamic&& params) override;
62+
void invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) override;
6363
MethodCallResult callSerializableNativeHook(unsigned int reactMethodId, folly::dynamic&& params) override;
6464

6565
private:
@@ -80,7 +80,7 @@ class NewJavaNativeModule : public NativeModule {
8080
std::string getName() override;
8181
std::vector<MethodDescriptor> getMethods() override;
8282
folly::dynamic getConstants() override;
83-
void invoke(unsigned int reactMethodId, folly::dynamic&& params) override;
83+
void invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) override;
8484
MethodCallResult callSerializableNativeHook(unsigned int reactMethodId, folly::dynamic&& params) override;
8585

8686
private:

ReactCommon/cxxreact/CxxNativeModule.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
#include <folly/json.h>
99

10-
#include <cxxreact/JsArgumentHelpers.h>
10+
#include "JsArgumentHelpers.h"
11+
#include "SystraceSection.h"
1112

1213
using facebook::xplat::module::CxxModule;
1314

@@ -75,7 +76,7 @@ folly::dynamic CxxNativeModule::getConstants() {
7576
return constants;
7677
}
7778

78-
void CxxNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params) {
79+
void CxxNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) {
7980
if (reactMethodId >= methods_.size()) {
8081
throw std::invalid_argument(folly::to<std::string>("methodId ", reactMethodId,
8182
" out of range [0..", methods_.size(), "]"));
@@ -128,7 +129,13 @@ void CxxNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params
128129
// stack. I'm told that will be possible in the future. TODO
129130
// mhorowitz #7128529: convert C++ exceptions to Java
130131

131-
messageQueueThread_->runOnQueue([method, params=std::move(params), first, second] () {
132+
messageQueueThread_->runOnQueue([method, params=std::move(params), first, second, callId] () {
133+
#ifdef WITH_FBSYSTRACE
134+
if (callId != -1) {
135+
fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
136+
}
137+
#endif
138+
SystraceSection s(method.name.c_str());
132139
try {
133140
method.func(std::move(params), first, second);
134141
} catch (const facebook::xplat::JsArgumentException& ex) {

0 commit comments

Comments
 (0)