@samitouri / QOS-React / commits / a77dd13ede

Delete enableDiscreteEventFlushingChange (#21110)

This flag was meant to avoid flushing discrete updates unnecessarily, if multiple discrete events were dispatched in response to the same platform event. But since we now flush all discrete events at the end of the task, in a microtask, it no longer has any effect.

Andrew Clark committed Mar 26, 2021 at 00:05 UTC a77dd13ede337175e94a7a1d4198ff440a5cd87b
10 files changed +4 -37
packages/react-dom/src/events/ReactDOMUpdateBatching.js
+4 -26
@@ -9,7 +9,6 @@ import {
9 needsStateRestore,
10 restoreStateIfNeeded,
11 } from './ReactDOMControlledComponent';
12 -import {enableDiscreteEventFlushingChange} from 'shared/ReactFeatureFlags';
12
13 // Used as a way to call batchedUpdates when we don't have a reference to
14 // the renderer. Such as when we're dispatching events or if third party
@@ -75,6 +74,7 @@ export function batchedEventUpdates(fn, a, b) {
74 }
75 }
76
77 +// TODO: Replace with flushSync
78 export function discreteUpdates(fn, a, b, c, d) {
79 const prevIsInsideEventHandler = isInsideEventHandler;
80 isInsideEventHandler = true;
@@ -88,32 +88,10 @@ export function discreteUpdates(fn, a, b, c, d) {
88 }
89 }
90
91 -let lastFlushedEventTimeStamp = 0;
91 +// TODO: Replace with flushSync
92 export function flushDiscreteUpdatesIfNeeded(timeStamp: number) {
93 - if (enableDiscreteEventFlushingChange) {
94 - // event.timeStamp isn't overly reliable due to inconsistencies in
95 - // how different browsers have historically provided the time stamp.
96 - // Some browsers provide high-resolution time stamps for all events,
97 - // some provide low-resolution time stamps for all events. FF < 52
98 - // even mixes both time stamps together. Some browsers even report
99 - // negative time stamps or time stamps that are 0 (iOS9) in some cases.
100 - // Given we are only comparing two time stamps with equality (!==),
101 - // we are safe from the resolution differences. If the time stamp is 0
102 - // we bail-out of preventing the flush, which can affect semantics,
103 - // such as if an earlier flush removes or adds event listeners that
104 - // are fired in the subsequent flush. However, this is the same
105 - // behaviour as we had before this change, so the risks are low.
106 - if (
107 - !isInsideEventHandler &&
108 - (timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)
109 - ) {
110 - lastFlushedEventTimeStamp = timeStamp;
111 - flushDiscreteUpdatesImpl();
112 - }
113 - } else {
114 - if (!isInsideEventHandler) {
115 - flushDiscreteUpdatesImpl();
116 - }
93 + if (!isInsideEventHandler) {
94 + flushDiscreteUpdatesImpl();
95 }
96 }
97
packages/shared/ReactFeatureFlags.js
-2
@@ -155,8 +155,6 @@ export const enableLegacyFBSupport = false;
155 // new behavior.
156 export const deferRenderPhaseUpdateToNextBatch = true;
157
158 -export const enableDiscreteEventFlushingChange = false;
159 -
158 export const enableUseRefAccessWarning = false;
159
160 export const enableRecursiveCommitTraversal = false;
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -50,7 +50,6 @@ export const deletedTreeCleanUpLevel = 1;
50
51 export const enableNewReconciler = false;
52 export const deferRenderPhaseUpdateToNextBatch = true;
53 -export const enableDiscreteEventFlushingChange = false;
53
54 export const enableStrictEffects = false;
55 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = false;
52
53 export const enableStrictEffects = false;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = false;
52
53 export const enableStrictEffects = false;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = false;
52
53 export const enableStrictEffects = false;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = false;
52
53 export const enableStrictEffects = true;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.testing.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = false;
52
53 export const enableStrictEffects = false;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
-1
@@ -49,7 +49,6 @@ export const deletedTreeCleanUpLevel = 1;
49
50 export const enableNewReconciler = false;
51 export const deferRenderPhaseUpdateToNextBatch = true;
52 -export const enableDiscreteEventFlushingChange = true;
52
53 export const enableStrictEffects = false;
54 export const createRootStrictEffectsByDefault = false;
packages/shared/forks/ReactFeatureFlags.www.js
-2
@@ -83,8 +83,6 @@ export const disableTextareaChildren = __EXPERIMENTAL__;
83
84 export const warnUnstableRenderSubtreeIntoContainer = false;
85
86 -export const enableDiscreteEventFlushingChange = true;
87 -
86 // Enable forked reconciler. Piggy-backing on the "variant" global so that we
87 // don't have to add another test dimension. The build system will compile this
88 // to the correct value.