Skip to content

Commit

Permalink
[Fiber] Use real event priority for hydration scheduling (#28765)
Browse files Browse the repository at this point in the history
Stacked on #28751

Historically explicit hydration scheduling used the reconciler's update
priority to schedule the hydration. There was a lingering todo to switch
to using event priority in the absence of an explicit update priority.
This change updates the hydration priority by referring to the event
priority if no update priority is set

DiffTrain build for [1f8327f](1f8327f)
  • Loading branch information
gnoff committed Apr 8, 2024
1 parent 7739cd4 commit 3c33835
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 124 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
97c90ed8835401e325e42de22f38a803c5e6fc6d
1f8327f834d923aa5a99cc0e81d2c9fc9d38c75d
7 changes: 2 additions & 5 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -36178,7 +36178,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-42767cb4";
var ReactVersion = "19.0.0-www-classic-6e6631b7";

function createPortal$1(
children,
Expand Down Expand Up @@ -47694,10 +47694,7 @@ if (__DEV__) {
}

function queueExplicitHydrationTarget(target) {
// TODO: This will read the priority if it's dispatched by the React
// event system but not native events. Should read window.event.type, like
// we do for updates (getCurrentEventPriority).
var updatePriority = getCurrentUpdatePriority();
var updatePriority = resolveUpdatePriority();
var queuedTarget = {
blockedOn: null,
target: target,
Expand Down
7 changes: 2 additions & 5 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -45657,7 +45657,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-modern-4bf48d34";
var ReactVersion = "19.0.0-www-modern-c711ae33";

function createPortal$1(
children,
Expand Down Expand Up @@ -46913,10 +46913,7 @@ if (__DEV__) {
}

function queueExplicitHydrationTarget(target) {
// TODO: This will read the priority if it's dispatched by the React
// event system but not native events. Should read window.event.type, like
// we do for updates (getCurrentEventPriority).
var updatePriority = getCurrentUpdatePriority();
var updatePriority = resolveUpdatePriority();
var queuedTarget = {
blockedOn: null,
target: target,
Expand Down
49 changes: 25 additions & 24 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ var Internals = {
p: 0,
findDOMNode: null
};
function resolveUpdatePriority() {
var updatePriority = Internals.p;
if (0 !== updatePriority) return updatePriority;
updatePriority = window.event;
return void 0 === updatePriority ? 32 : getEventPriority(updatePriority.type);
}
function runWithPriority(priority, fn) {
var previousPriority = Internals.p;
try {
Expand Down Expand Up @@ -10794,19 +10800,14 @@ var legacyErrorBoundariesThatAlreadyFailed = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null;
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 2;
if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
if (null !== requestCurrentTransition())
return (
(fiber = currentEntangledLane),
0 !== fiber ? fiber : requestTransitionLane()
);
fiber = Internals.p;
0 === fiber &&
((fiber = window.event),
(fiber = void 0 === fiber ? 32 : getEventPriority(fiber.type)));
return fiber;
return 0 === (fiber.mode & 1)
? 2
: 0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes
? workInProgressRootRenderLanes & -workInProgressRootRenderLanes
: null !== requestCurrentTransition()
? ((fiber = currentEntangledLane),
0 !== fiber ? fiber : requestTransitionLane())
: resolveUpdatePriority();
}
function requestDeferredLane() {
0 === workInProgressDeferredLane &&
Expand Down Expand Up @@ -16904,7 +16905,7 @@ function ReactDOMHydrationRoot(internalRoot) {
}
ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
if (target) {
var updatePriority = Internals.p;
var updatePriority = resolveUpdatePriority();
target = { blockedOn: null, target: target, priority: updatePriority };
for (
var i = 0;
Expand Down Expand Up @@ -16979,10 +16980,10 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1727 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-0213c015",
version: "19.0.0-www-classic-5535d565",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2160 = {
var internals$jscomp$inline_2156 = {
bundleType: devToolsConfig$jscomp$inline_1727.bundleType,
version: devToolsConfig$jscomp$inline_1727.version,
rendererPackageName: devToolsConfig$jscomp$inline_1727.rendererPackageName,
Expand All @@ -17009,19 +17010,19 @@ var internals$jscomp$inline_2160 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-0213c015"
reconcilerVersion: "19.0.0-www-classic-5535d565"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2161 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_2157 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_2161.isDisabled &&
hook$jscomp$inline_2161.supportsFiber
!hook$jscomp$inline_2157.isDisabled &&
hook$jscomp$inline_2157.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_2161.inject(
internals$jscomp$inline_2160
(rendererID = hook$jscomp$inline_2157.inject(
internals$jscomp$inline_2156
)),
(injectedHook = hook$jscomp$inline_2161);
(injectedHook = hook$jscomp$inline_2157);
} catch (err) {}
}
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
Expand Down Expand Up @@ -17475,4 +17476,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-0213c015";
exports.version = "19.0.0-www-classic-5535d565";
37 changes: 18 additions & 19 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ function popHostContext(fiber) {
(HostTransitionContext._currentValue = null));
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function resolveUpdatePriority() {
var updatePriority = Internals.p;
if (0 !== updatePriority) return updatePriority;
updatePriority = window.event;
return void 0 === updatePriority ? 32 : getEventPriority(updatePriority.type);
}
function runWithPriority(priority, fn) {
var previousPriority = Internals.p;
try {
Expand Down Expand Up @@ -13398,14 +13404,7 @@ function requestUpdateLane() {
var actionScopeLane = currentEntangledLane;
return 0 !== actionScopeLane ? actionScopeLane : requestTransitionLane();
}
actionScopeLane = Internals.p;
0 === actionScopeLane &&
((actionScopeLane = window.event),
(actionScopeLane =
void 0 === actionScopeLane
? 32
: getEventPriority(actionScopeLane.type)));
return actionScopeLane;
return resolveUpdatePriority();
}
function requestDeferredLane() {
0 === workInProgressDeferredLane &&
Expand Down Expand Up @@ -16267,7 +16266,7 @@ function ReactDOMHydrationRoot(internalRoot) {
}
ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
if (target) {
var updatePriority = Internals.p;
var updatePriority = resolveUpdatePriority();
target = { blockedOn: null, target: target, priority: updatePriority };
for (
var i = 0;
Expand Down Expand Up @@ -16344,10 +16343,10 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1720 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-c8552266",
version: "19.0.0-www-modern-a0bffb4d",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2162 = {
var internals$jscomp$inline_2158 = {
bundleType: devToolsConfig$jscomp$inline_1720.bundleType,
version: devToolsConfig$jscomp$inline_1720.version,
rendererPackageName: devToolsConfig$jscomp$inline_1720.rendererPackageName,
Expand All @@ -16374,19 +16373,19 @@ var internals$jscomp$inline_2162 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-c8552266"
reconcilerVersion: "19.0.0-www-modern-a0bffb4d"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2163 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_2159 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_2163.isDisabled &&
hook$jscomp$inline_2163.supportsFiber
!hook$jscomp$inline_2159.isDisabled &&
hook$jscomp$inline_2159.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_2163.inject(
internals$jscomp$inline_2162
(rendererID = hook$jscomp$inline_2159.inject(
internals$jscomp$inline_2158
)),
(injectedHook = hook$jscomp$inline_2163);
(injectedHook = hook$jscomp$inline_2159);
} catch (err) {}
}
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
Expand Down Expand Up @@ -16683,4 +16682,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-c8552266";
exports.version = "19.0.0-www-modern-a0bffb4d";
35 changes: 18 additions & 17 deletions compiled/facebook-www/ReactDOM-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,12 @@ var Internals = {
p: 0,
findDOMNode: null
};
function resolveUpdatePriority() {
var updatePriority = Internals.p;
if (0 !== updatePriority) return updatePriority;
updatePriority = window.event;
return void 0 === updatePriority ? 32 : getEventPriority(updatePriority.type);
}
function runWithPriority(priority, fn) {
var previousPriority = Internals.p;
try {
Expand Down Expand Up @@ -11385,19 +11391,14 @@ var legacyErrorBoundariesThatAlreadyFailed = null,
nestedUpdateCount = 0,
rootWithNestedUpdates = null;
function requestUpdateLane(fiber) {
if (0 === (fiber.mode & 1)) return 2;
if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes)
return workInProgressRootRenderLanes & -workInProgressRootRenderLanes;
if (null !== requestCurrentTransition())
return (
(fiber = currentEntangledLane),
0 !== fiber ? fiber : requestTransitionLane()
);
fiber = Internals.p;
0 === fiber &&
((fiber = window.event),
(fiber = void 0 === fiber ? 32 : getEventPriority(fiber.type)));
return fiber;
return 0 === (fiber.mode & 1)
? 2
: 0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes
? workInProgressRootRenderLanes & -workInProgressRootRenderLanes
: null !== requestCurrentTransition()
? ((fiber = currentEntangledLane),
0 !== fiber ? fiber : requestTransitionLane())
: resolveUpdatePriority();
}
function requestDeferredLane() {
0 === workInProgressDeferredLane &&
Expand Down Expand Up @@ -17652,7 +17653,7 @@ function ReactDOMHydrationRoot(internalRoot) {
}
ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
if (target) {
var updatePriority = Internals.p;
var updatePriority = resolveUpdatePriority();
target = { blockedOn: null, target: target, priority: updatePriority };
for (
var i = 0;
Expand Down Expand Up @@ -17727,7 +17728,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1813 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-59814ebe",
version: "19.0.0-www-classic-fe45242c",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -17771,7 +17772,7 @@ var devToolsConfig$jscomp$inline_1813 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-59814ebe"
reconcilerVersion: "19.0.0-www-classic-fe45242c"
});
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog)
Expand Down Expand Up @@ -18224,7 +18225,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-59814ebe";
exports.version = "19.0.0-www-classic-fe45242c";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
23 changes: 11 additions & 12 deletions compiled/facebook-www/ReactDOM-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,12 @@ function popHostContext(fiber) {
(HostTransitionContext._currentValue = null));
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function resolveUpdatePriority() {
var updatePriority = Internals.p;
if (0 !== updatePriority) return updatePriority;
updatePriority = window.event;
return void 0 === updatePriority ? 32 : getEventPriority(updatePriority.type);
}
function runWithPriority(priority, fn) {
var previousPriority = Internals.p;
try {
Expand Down Expand Up @@ -13984,14 +13990,7 @@ function requestUpdateLane() {
var actionScopeLane = currentEntangledLane;
return 0 !== actionScopeLane ? actionScopeLane : requestTransitionLane();
}
actionScopeLane = Internals.p;
0 === actionScopeLane &&
((actionScopeLane = window.event),
(actionScopeLane =
void 0 === actionScopeLane
? 32
: getEventPriority(actionScopeLane.type)));
return actionScopeLane;
return resolveUpdatePriority();
}
function requestDeferredLane() {
0 === workInProgressDeferredLane &&
Expand Down Expand Up @@ -16998,7 +16997,7 @@ function ReactDOMHydrationRoot(internalRoot) {
}
ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
if (target) {
var updatePriority = Internals.p;
var updatePriority = resolveUpdatePriority();
target = { blockedOn: null, target: target, priority: updatePriority };
for (
var i = 0;
Expand Down Expand Up @@ -17075,7 +17074,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1806 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-3a232590",
version: "19.0.0-www-modern-f5d53e66",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -17119,7 +17118,7 @@ var devToolsConfig$jscomp$inline_1806 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-3a232590"
reconcilerVersion: "19.0.0-www-modern-f5d53e66"
});
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog)
Expand Down Expand Up @@ -17415,7 +17414,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-3a232590";
exports.version = "19.0.0-www-modern-f5d53e66";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
7 changes: 2 additions & 5 deletions compiled/facebook-www/ReactDOMTesting-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -36802,7 +36802,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-45fdacd4";
var ReactVersion = "19.0.0-www-classic-a0e8cd8c";

function createPortal$1(
children,
Expand Down Expand Up @@ -48450,10 +48450,7 @@ if (__DEV__) {
}

function queueExplicitHydrationTarget(target) {
// TODO: This will read the priority if it's dispatched by the React
// event system but not native events. Should read window.event.type, like
// we do for updates (getCurrentEventPriority).
var updatePriority = getCurrentUpdatePriority();
var updatePriority = resolveUpdatePriority();
var queuedTarget = {
blockedOn: null,
target: target,
Expand Down
Loading

0 comments on commit 3c33835

Please sign in to comment.