File tree Expand file tree Collapse file tree
packages/react-reconciler/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,6 +254,23 @@ function FiberNode(
254254 this . alternate = null ;
255255
256256 if ( enableProfilerTimer ) {
257+ // Note: The following is done to avoid a v8 deopt.
258+ //
259+ // It is important to initialize the fields below with doubles.
260+ // Otherwise Fibers will deopt and end up having separate shapes when
261+ // doubles are later assigned to fields that initially contained smis.
262+ // This is a bug in v8 having something to do with Object.preventExtension().
263+ //
264+ // Learn more about this deopt here:
265+ // https://github.com/facebook/react/issues/14365
266+ // https://bugs.chromium.org/p/v8/issues/detail?id=8538
267+ this . actualDuration = Number . NaN ;
268+ this . actualStartTime = Number . NaN ;
269+ this . selfBaseDuration = Number . NaN ;
270+ this . treeBaseDuration = Number . NaN ;
271+
272+ // It's okay to replace the initial doubles with smis after initialization.
273+ // This simplifies other profiler code and doesn't trigger the deopt.
257274 this . actualDuration = 0 ;
258275 this . actualStartTime = - 1 ;
259276 this . selfBaseDuration = 0 ;
You can’t perform that action at this time.
0 commit comments