Inject early on when reloading-and-profiling

This commit is contained in:
Brian Vaughn committed 2019-04-01 07:48:14 -07:00
1 parent 37ed5a7175
commit 2c14f3e88e
10 files changed
+107 -20

No files matched your search

+1 -3
View File
@@ -1,7 +1,7 @@
// @flow
import EventEmitter from 'events';
import { __DEBUG__ } from '../constants';
import { RELOAD_AND_PROFILE_KEY, __DEBUG__ } from '../constants';
import { hideOverlay, showOverlay } from './views/Highlighter';
import type { RendererID, RendererInterface } from './types';
@@ -38,8 +38,6 @@ type SetInParams = {|
value: any,
|};
const RELOAD_AND_PROFILE_KEY = 'React::DevTools::reloadAndProfile';
export default class Agent extends EventEmitter {
_bridge: Bridge = ((null: any): Bridge);
_isProfiling: boolean = false;
+10 -2
View File
@@ -33,8 +33,16 @@ export function initBackend(
];
const attachRenderer = (id: number, renderer: ReactRenderer) => {
const rendererInterface = attach(hook, id, renderer, global);
hook.rendererInterfaces.set(id, rendererInterface);
let rendererInterface = hook.rendererInterfaces.get(id);
// Inject any not-yet-injected renderers (if we didn't reload-and-profile)
if (!rendererInterface) {
rendererInterface = attach(hook, id, renderer, global);
hook.rendererInterfaces.set(id, rendererInterface);
}
// Notify the DevTools frontend about any renderers that were attached early.
hook.emit('renderer-attached', {
id,
renderer,
+9
View File
@@ -1595,6 +1595,10 @@ export function attach(
}
function startProfiling() {
if (isProfiling) {
return;
}
// Capture initial values as of the time profiling starts.
// It's important we snapshot both the durations and the id-to-root map,
// since either of these may change during the profiling session
@@ -1611,6 +1615,11 @@ export function attach(
isProfiling = false;
}
// Automatically start profiling so that we don't miss timing info from initial "mount".
if (localStorage.getItem('React::DevTools::reloadAndProfile') === 'true') {
startProfiling();
}
return {
cleanup,
getCommitDetails,