Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Share the VERSION constant between scheduling profiler marks and pre-…
…processor
  • Loading branch information
Brian Vaughn committed Aug 5, 2021
commit 5ad8a2f614583f453178bc473d3f5a7c326fbb91
3 changes: 3 additions & 0 deletions packages/react-devtools-scheduling-profiler/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ export {
} from 'react-devtools-shared/src/constants.js';

export const REACT_TOTAL_NUM_LANES = 31;

// Increment this number any time a backwards breaking change is made to the profiler metadata.
export const SCHEDULING_PROFILER_VERSION = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import {getLaneLabels} from 'react-reconciler/src/SchedulingProfiler';
import preprocessData, {
SUPPORTED_PROFILER_VERSION,
getLanesFromTransportDecimalBitmask,
} from '../preprocessData';
import {REACT_TOTAL_NUM_LANES} from '../../constants';
import {
REACT_TOTAL_NUM_LANES,
SCHEDULING_PROFILER_VERSION,
} from '../../constants';
import REACT_VERSION from 'shared/ReactVersion';

describe(getLanesFromTransportDecimalBitmask, () => {
Expand Down Expand Up @@ -115,7 +117,7 @@ describe(preprocessData, () => {
function createProfilerVersionEntry() {
return createUserTimingEntry({
cat: 'blink.user_timing',
name: '--profiler-version-' + SUPPORTED_PROFILER_VERSION,
name: '--profiler-version-' + SCHEDULING_PROFILER_VERSION,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
SuspenseEvent,
} from '../types';

import {REACT_TOTAL_NUM_LANES} from '../constants';
import {REACT_TOTAL_NUM_LANES, SCHEDULING_PROFILER_VERSION} from '../constants';
import InvalidProfileError from './InvalidProfileError';

type MeasureStackElement = {|
Expand All @@ -46,10 +46,6 @@ type ProcessorState = {|
unresolvedSuspenseEvents: Map<string, SuspenseEvent>,
|};

// Increment this number any time a backwards breaking change is made to the profiler metadata.
// It should be in sync with the version in react-reconciler/src/SchedulingProfiler
export const SUPPORTED_PROFILER_VERSION = 1;

const NATIVE_EVENT_DURATION_THRESHOLD = 20;

const WARNING_STRINGS = {
Expand Down Expand Up @@ -268,7 +264,7 @@ function processTimelineEvent(
} else if (name.startsWith('--profiler-version-')) {
const [versionString] = name.substr(19).split('-');
profilerVersion = parseInt(versionString, 10);
if (profilerVersion !== SUPPORTED_PROFILER_VERSION) {
if (profilerVersion !== SCHEDULING_PROFILER_VERSION) {
throw new InvalidProfileError(
`This version of profiling data (${versionString}) is not supported by the current profiler.`,
);
Expand Down
7 changes: 2 additions & 5 deletions packages/react-reconciler/src/SchedulingProfiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from 'shared/ReactFeatureFlags';
import ReactVersion from 'shared/ReactVersion';
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
import {SCHEDULING_PROFILER_VERSION} from 'react-devtools-scheduling-profiler/src/constants';

import {
getLabelForLane as getLabelForLane_old,
Expand All @@ -33,10 +34,6 @@ const getLabelForLane = enableNewReconciler

const TotalLanes = enableNewReconciler ? TotalLanes_new : TotalLanes_old;

// Increment this number any time a backwards breaking change is made to the profiler metadata.
// It should be in sync with the version in react-devtoos-scheduling-profiler/src/import-worker/preprocessData
const PROFILER_VERSION = 1;

/**
* If performance exists and supports the subset of the User Timing API that we
* require.
Expand Down Expand Up @@ -98,7 +95,7 @@ function markAndClear(name) {

function markVersionMetadata() {
markAndClear(`--react-version-${ReactVersion}`);
markAndClear(`--profiler-version-${PROFILER_VERSION}`);
markAndClear(`--profiler-version-${SCHEDULING_PROFILER_VERSION}`);
}

export function markCommitStarted(lanes: Lanes): void {
Expand Down