File tree 1 file changed +17
-0
lines changed
packages/react-reconciler/src
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,23 @@ function FiberNode(
254
254
this . alternate = null ;
255
255
256
256
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.
257
274
this . actualDuration = 0 ;
258
275
this . actualStartTime = - 1 ;
259
276
this . selfBaseDuration = 0 ;
You can’t perform that action at this time.
0 commit comments