Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/react-native
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d8e1e996c9b32f6c52e016208c5e219dbccac497
Choose a base ref
..
head repository: facebook/react-native
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 33e3799767fd6b75ba615969c20934c61667c1f2
Choose a head ref
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@

// flowlint unsafe-getters-setters:off

export type MemoryInfoLike = {
type MemoryInfoLike = {
jsHeapSizeLimit: ?number,
totalJSHeapSize: ?number,
usedJSHeapSize: ?number,
Original file line number Diff line number Diff line change
@@ -54,23 +54,41 @@ std::unordered_map<std::string, double> NativePerformance::getSimpleMemoryInfo(
return heapInfoToJs;
}

ReactNativeStartupTiming NativePerformance::getReactNativeStartupTiming(
jsi::Runtime &rt) {
ReactNativeStartupTiming result = {0, 0, 0, 0, 0, 0};
std::unordered_map<std::string, double>
NativePerformance::getReactNativeStartupTiming(jsi::Runtime &rt) {
std::unordered_map<std::string, double> result;

ReactMarker::StartupLogger &startupLogger =
ReactMarker::StartupLogger::getInstance();
result.startTime = startupLogger.getAppStartupStartTime();
if (result.startTime == 0) {
result.startTime = startupLogger.getInitReactRuntimeStartTime();
if (!std::isnan(startupLogger.getAppStartupStartTime())) {
result["startTime"] = startupLogger.getAppStartupStartTime();
} else if (!std::isnan(startupLogger.getInitReactRuntimeStartTime())) {
result["startTime"] = startupLogger.getInitReactRuntimeStartTime();
}

if (!std::isnan(startupLogger.getInitReactRuntimeStartTime())) {
result["initializeRuntimeStart"] =
startupLogger.getInitReactRuntimeStartTime();
}

if (!std::isnan(startupLogger.getRunJSBundleStartTime())) {
result["executeJavaScriptBundleEntryPointStart"] =
startupLogger.getRunJSBundleStartTime();
}

if (!std::isnan(startupLogger.getRunJSBundleEndTime())) {
result["executeJavaScriptBundleEntryPointEnd"] =
startupLogger.getRunJSBundleEndTime();
}

if (!std::isnan(startupLogger.getInitReactRuntimeEndTime())) {
result["initializeRuntimeEnd"] = startupLogger.getInitReactRuntimeEndTime();
}
result.initializeRuntimeStart = startupLogger.getInitReactRuntimeStartTime();
result.executeJavaScriptBundleEntryPointStart =
startupLogger.getRunJSBundleStartTime();
result.executeJavaScriptBundleEntryPointEnd =
startupLogger.getRunJSBundleEndTime();
result.initializeRuntimeEnd = startupLogger.getInitReactRuntimeEndTime();
result.endTime = startupLogger.getAppStartupEndTime();

if (!std::isnan(startupLogger.getAppStartupEndTime())) {
result["endTime"] = startupLogger.getAppStartupEndTime();
}

return result;
}

22 changes: 2 additions & 20 deletions packages/react-native/Libraries/WebPerformance/NativePerformance.h
Original file line number Diff line number Diff line change
@@ -18,25 +18,6 @@ class PerformanceEntryReporter;

#pragma mark - Structs

using ReactNativeStartupTiming =
NativePerformanceCxxBaseReactNativeStartupTiming<
int32_t,
int32_t,
int32_t,
int32_t,
int32_t,
int32_t>;

template <>
struct Bridging<ReactNativeStartupTiming>
: NativePerformanceCxxBaseReactNativeStartupTimingBridging<
int32_t,
int32_t,
int32_t,
int32_t,
int32_t,
int32_t> {};

#pragma mark - implementation

class NativePerformance : public NativePerformanceCxxSpec<NativePerformance>,
@@ -70,7 +51,8 @@ class NativePerformance : public NativePerformanceCxxSpec<NativePerformance>,

// Collect and return the RN app startup timing information for performance
// tracking.
ReactNativeStartupTiming getReactNativeStartupTiming(jsi::Runtime &rt);
std::unordered_map<std::string, double> getReactNativeStartupTiming(
jsi::Runtime &rt);

private:
};
Original file line number Diff line number Diff line change
@@ -12,16 +12,9 @@ import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export type NativeMemoryInfo = {[key: string]: number};
export type NativeMemoryInfo = {[key: string]: ?number};

export type ReactNativeStartupTiming = {|
startTime: number,
endTime: number,
initializeRuntimeStart: number,
initializeRuntimeEnd: number,
executeJavaScriptBundleEntryPointStart: number,
executeJavaScriptBundleEntryPointEnd: number,
|};
export type ReactNativeStartupTiming = {[key: string]: ?number};

export interface Spec extends TurboModule {
+mark: (name: string, startTime: number) => void;
19 changes: 16 additions & 3 deletions packages/react-native/Libraries/WebPerformance/Performance.js
Original file line number Diff line number Diff line change
@@ -143,9 +143,22 @@ export default class Performance {
// Startup metrics is not used in web, but only in React Native.
get reactNativeStartupTiming(): ReactNativeStartupTiming {
if (NativePerformance?.getReactNativeStartupTiming) {
return new ReactNativeStartupTiming(
NativePerformance.getReactNativeStartupTiming(),
);
const {
startTime,
endTime,
initializeRuntimeStart,
initializeRuntimeEnd,
executeJavaScriptBundleEntryPointStart,
executeJavaScriptBundleEntryPointEnd,
} = NativePerformance.getReactNativeStartupTiming();
return new ReactNativeStartupTiming({
startTime,
endTime,
initializeRuntimeStart,
initializeRuntimeEnd,
executeJavaScriptBundleEntryPointStart,
executeJavaScriptBundleEntryPointEnd,
});
}
return new ReactNativeStartupTiming();
}
Original file line number Diff line number Diff line change
@@ -11,22 +11,30 @@

// flowlint unsafe-getters-setters:off

import type {ReactNativeStartupTiming as ReactNativeStartupTimingType} from './NativePerformance';
type ReactNativeStartupTimingLike = {
startTime: ?number,
endTime: ?number,
initializeRuntimeStart: ?number,
initializeRuntimeEnd: ?number,
executeJavaScriptBundleEntryPointStart: ?number,
executeJavaScriptBundleEntryPointEnd: ?number,
};

// Read-only object with RN startup timing information.
// This is returned by the performance.reactNativeStartup API.
export default class ReactNativeStartupTiming {
// All time information here are in ms. To match web spec,
// the default value for timings are zero if not present.
// See https://www.w3.org/TR/performance-timeline/#performancetiming-interface
_startTime = 0;
_endTime = 0;
_initializeRuntimeStart = 0;
_initializeRuntimeEnd = 0;
_executeJavaScriptBundleEntryPointStart = 0;
_executeJavaScriptBundleEntryPointEnd = 0;
// All time information here are in ms. The values may be null if not provided.
// We do NOT match web spect here for two reasons:
// 1. The `ReactNativeStartupTiming` is non-standard API
// 2. The timing information is relative to the time origin, which means `0` has valid meaning
_startTime: ?number;
_endTime: ?number;
_initializeRuntimeStart: ?number;
_initializeRuntimeEnd: ?number;
_executeJavaScriptBundleEntryPointStart: ?number;
_executeJavaScriptBundleEntryPointEnd: ?number;

constructor(startUpTiming: ?ReactNativeStartupTimingType) {
constructor(startUpTiming: ?ReactNativeStartupTimingLike) {
if (startUpTiming != null) {
this._startTime = startUpTiming.startTime;
this._endTime = startUpTiming.endTime;
@@ -42,42 +50,42 @@ export default class ReactNativeStartupTiming {
/**
* Start time of the RN app startup process. This is provided by the platform by implementing the `ReactMarker.setAppStartTime` API in the native platform code.
*/
get startTime(): number {
get startTime(): ?number {
return this._startTime;
}

/**
* End time of the RN app startup process. This is equal to `executeJavaScriptBundleEntryPointEnd`.
*/
get endTime(): number {
get endTime(): ?number {
return this._endTime;
}

/**
* Start time when RN runtime get initialized. This is when RN infra first kicks in app startup process.
*/
get initializeRuntimeStart(): number {
get initializeRuntimeStart(): ?number {
return this._initializeRuntimeStart;
}

/**
* End time when RN runtime get initialized. This is the last marker before ends of the app startup process.
*/
get initializeRuntimeEnd(): number {
get initializeRuntimeEnd(): ?number {
return this._initializeRuntimeEnd;
}

/**
* Start time of JS bundle being executed. This indicates the RN JS bundle is loaded and start to be evaluated.
*/
get executeJavaScriptBundleEntryPointStart(): number {
get executeJavaScriptBundleEntryPointStart(): ?number {
return this._executeJavaScriptBundleEntryPointStart;
}

/**
* End time of JS bundle being executed. This indicates all the synchronous entry point jobs are finished.
*/
get executeJavaScriptBundleEntryPointEnd(): number {
get executeJavaScriptBundleEntryPointEnd(): ?number {
return this._executeJavaScriptBundleEntryPointEnd;
}
}
Original file line number Diff line number Diff line change
@@ -393,6 +393,11 @@ public BoxedColorPropSetter(ReactProp prop, Method setter) {
*/
/*package*/ static Map<String, PropSetter> getNativePropSettersForShadowNodeClass(
Class<? extends ReactShadowNode> cls) {
if (cls == null) {
return EMPTY_PROPS_MAP;
}
;

for (Class iface : cls.getInterfaces()) {
if (iface == ReactShadowNode.class) {
return EMPTY_PROPS_MAP;
Original file line number Diff line number Diff line change
@@ -274,10 +274,16 @@ void FabricMountingManager::executeMount(
std::lock_guard allocatedViewsLock(allocatedViewsMutex_);

auto allocatedViewsIterator = allocatedViewRegistry_.find(surfaceId);
auto const &allocatedViewTags =
auto defaultAllocatedViews = butter::set<Tag>{};
// Do not remove `defaultAllocatedViews` or initialize `butter::set<Tag>{}`
// inline in below ternary expression -
// if falsy operand is a value type, the compiler will decide the expression
// to be a value type, an unnecessary (sometimes expensive) copy will happen
// as a result.
const auto &allocatedViewTags =
allocatedViewsIterator != allocatedViewRegistry_.end()
? allocatedViewsIterator->second
: butter::set<Tag>{};
: defaultAllocatedViews;
if (allocatedViewsIterator == allocatedViewRegistry_.end()) {
LOG(ERROR) << "Executing commit after surface was stopped!";
}
Loading