Permalink
Browse files

Updated Systrace and RCTRenderingPerf to sync w/ React changes

Summary:
A temporary React Native compatibility fix was added to React in commit [bba0d99](facebook/react@bba0d99) and subsequently removed in commit [e612826](facebook/react@e612826). I noticed this while testing the React Native fiber renderer and attempting to use `Systrace`.

This commit updates React Native to no longer rely on the deprecated method and module.

PS I'm not sure if I should also update `ReactDebugTool` with this commit or wait for a subsequent sync script to update it. I haven't committed to this repo before. Please advise. 😄
Closes #11970

Differential Revision: D4446219

Pulled By: bvaughn

fbshipit-source-id: f286b8a4d00cdcbfbb49f52b9f1db5231d453f4c
  • Loading branch information...
bvaughn authored and facebook-github-bot committed Jan 22, 2017
1 parent 16bb6e8 commit 212d31e3229b3836aeaba9e97f068394882728e9
@@ -54,7 +54,7 @@ var RCTRenderingPerf = {
}
ReactPerf.start();
ReactDebugTool.addDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.addHook(RCTRenderingPerfDevtool);
perfModules.forEach((module) => module.start());
},
@@ -66,7 +66,7 @@ var RCTRenderingPerf = {
ReactPerf.stop();
ReactPerf.printInclusive();
ReactPerf.printWasted();
ReactDebugTool.removeDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.removeHook(RCTRenderingPerfDevtool);
console.log(`Total time spent in render(): ${totalRenderDuration.toFixed(2)} ms`);
lastRenderStartTime = 0;
@@ -32,28 +32,28 @@ let _asyncCookie = 0;
const ReactSystraceDevtool = __DEV__ ? {
onBeforeMountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.mountComponent(${displayName})`);
},
onMountComponent(debugID) {
Systrace.endEvent();
},
onBeforeUpdateComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.updateComponent(${displayName})`);
},
onUpdateComponent(debugID) {
Systrace.endEvent();
},
onBeforeUnmountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.unmountComponent(${displayName})`);
},
onUnmountComponent(debugID) {
Systrace.endEvent();
},
onBeginLifeCycleTimer(debugID, timerType) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`${displayName}.${timerType}()`);
},
onEndLifeCycleTimer(debugID, timerType) {
@@ -67,10 +67,10 @@ const Systrace = {
if (__DEV__) {
if (enabled) {
global.nativeTraceBeginLegacy && global.nativeTraceBeginLegacy(TRACE_TAG_JSC_CALLS);
require('ReactDebugTool').addDevtool(ReactSystraceDevtool);
require('ReactDebugTool').addHook(ReactSystraceDevtool);
} else {
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JSC_CALLS);
require('ReactDebugTool').removeDevtool(ReactSystraceDevtool);
require('ReactDebugTool').removeHook(ReactSystraceDevtool);
}
}
_enabled = enabled;
@@ -409,10 +409,6 @@ var ReactDebugTool = {
},
};
// TODO remove these when RN/www gets updated
(ReactDebugTool: any).addDevtool = ReactDebugTool.addHook;
(ReactDebugTool: any).removeDevtool = ReactDebugTool.removeHook;
ReactDebugTool.addHook(ReactInvalidSetStateWarningHook);
ReactDebugTool.addHook(ReactComponentTreeHook);
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';

0 comments on commit 212d31e

Please sign in to comment.