RN: Remove React Stack Systrace Logic
Reviewed By: sophiebits Differential Revision: D7027263 fbshipit-source-id: f4eb3fab402eda337f464e4ebb0771202a9b93f2
This commit is contained in:
Родитель
4454fdc219
Коммит
973ef9728c
|
@ -54,7 +54,7 @@ if (!global.process.env.NODE_ENV) {
|
|||
// Setup the Systrace profiling hooks if necessary
|
||||
if (global.__RCTProfileIsProfiling) {
|
||||
const Systrace = require('Systrace');
|
||||
Systrace.installReactHook(true);
|
||||
Systrace.installReactHook();
|
||||
Systrace.setEnabled(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ let _asyncCookie = 0;
|
|||
const _markStack = [];
|
||||
let _markStackIndex = -1;
|
||||
let _canInstallReactHook = false;
|
||||
let _useFiber = false;
|
||||
|
||||
// Implements a subset of User Timing API necessary for React measurements.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API
|
||||
|
@ -98,54 +97,13 @@ const userTimingPolyfill = __DEV__ ? {
|
|||
},
|
||||
} : null;
|
||||
|
||||
// A hook to get React Stack markers in Systrace.
|
||||
const reactDebugToolHook = __DEV__ ? {
|
||||
onBeforeMountComponent(debugID) {
|
||||
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
|
||||
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
|
||||
Systrace.beginEvent(`ReactReconciler.mountComponent(${displayName})`);
|
||||
},
|
||||
onMountComponent(debugID) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
onBeforeUpdateComponent(debugID) {
|
||||
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
|
||||
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
|
||||
Systrace.beginEvent(`ReactReconciler.updateComponent(${displayName})`);
|
||||
},
|
||||
onUpdateComponent(debugID) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
onBeforeUnmountComponent(debugID) {
|
||||
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
|
||||
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
|
||||
Systrace.beginEvent(`ReactReconciler.unmountComponent(${displayName})`);
|
||||
},
|
||||
onUnmountComponent(debugID) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
onBeginLifeCycleTimer(debugID, timerType) {
|
||||
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
|
||||
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
|
||||
Systrace.beginEvent(`${displayName}.${timerType}()`);
|
||||
},
|
||||
onEndLifeCycleTimer(debugID, timerType) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
} : null;
|
||||
|
||||
const Systrace = {
|
||||
installReactHook(useFiber: boolean) {
|
||||
installReactHook() {
|
||||
if (_enabled) {
|
||||
if (__DEV__) {
|
||||
if (useFiber) {
|
||||
global.performance = userTimingPolyfill;
|
||||
} else {
|
||||
require('ReactDebugTool').addHook(reactDebugToolHook);
|
||||
}
|
||||
global.performance = userTimingPolyfill;
|
||||
}
|
||||
}
|
||||
_useFiber = useFiber;
|
||||
_canInstallReactHook = true;
|
||||
},
|
||||
|
||||
|
@ -158,17 +116,8 @@ const Systrace = {
|
|||
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JS_VM_CALLS);
|
||||
}
|
||||
if (_canInstallReactHook) {
|
||||
if (_useFiber) {
|
||||
if (enabled && global.performance === undefined) {
|
||||
global.performance = userTimingPolyfill;
|
||||
}
|
||||
} else {
|
||||
const ReactDebugTool = require('ReactDebugTool');
|
||||
if (enabled) {
|
||||
ReactDebugTool.addHook(reactDebugToolHook);
|
||||
} else {
|
||||
ReactDebugTool.removeHook(reactDebugToolHook);
|
||||
}
|
||||
if (enabled && global.performance === undefined) {
|
||||
global.performance = userTimingPolyfill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +189,7 @@ const Systrace = {
|
|||
attachToRelayProfiler(relayProfiler: RelayProfiler) {
|
||||
relayProfiler.attachProfileHandler('*', (name, state?) => {
|
||||
if (state != null && state.queryName !== undefined) {
|
||||
name += '_' + state.queryName
|
||||
name += '_' + state.queryName;
|
||||
}
|
||||
const cookie = Systrace.beginAsyncEvent(name);
|
||||
return () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче