Skip to content

Commit

Permalink
Updated Systrace and RCTRenderingPerf to sync w/ React changes
Browse files Browse the repository at this point in the history
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
Brian Vaughn authored and facebook-github-bot committed Jan 22, 2017
1 parent 16bb6e8 commit 212d31e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Libraries/Performance/RCTRenderingPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var RCTRenderingPerf = {
}

ReactPerf.start();
ReactDebugTool.addDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.addHook(RCTRenderingPerfDevtool);
perfModules.forEach((module) => module.start());
},

Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Libraries/Performance/Systrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions Libraries/Renderer/src/renderers/shared/ReactDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) || '';
Expand Down

0 comments on commit 212d31e

Please sign in to comment.