mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
set priority on TaskController instead of on postTask/yield (#27295)
## Summary
passing both a signal and a priority to `postTask`/`yield` in chrome
causes memory to spike and potentially causes OOMs. a fix for this has
landed in chrome 118, but we can avoid the issue in earlier versions by
setting priority on just the TaskController instead.
https://bugs.chromium.org/p/chromium/issues/detail?id=1469367
## How did you test this change?
```
yarn test SchedulerPostTask
```
DiffTrain build for [4129ea8c92](https://github.com/facebook/react/commit/4129ea8c922b950be3964f98d2bb74ff4a1c5431)
This commit is contained in:
@@ -1 +1 @@
|
||||
456d153bb582798effa76c09bec2405ab2e392cf
|
||||
4129ea8c922b950be3964f98d2bb74ff4a1c5431
|
||||
|
||||
@@ -34000,7 +34000,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-72a2d0d7";
|
||||
var ReactVersion = "18.3.0-www-classic-d49923a6";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
@@ -16688,7 +16688,7 @@ Internals.Events = [
|
||||
var devToolsConfig$jscomp$inline_1782 = {
|
||||
findFiberByHostInstance: getClosestInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-www-classic-a5b8c25c",
|
||||
version: "18.3.0-www-classic-96d8b30d",
|
||||
rendererPackageName: "react-dom"
|
||||
};
|
||||
var internals$jscomp$inline_2139 = {
|
||||
@@ -16718,7 +16718,7 @@ var internals$jscomp$inline_2139 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-www-classic-a5b8c25c"
|
||||
reconcilerVersion: "18.3.0-www-classic-96d8b30d"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_2140 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
@@ -16957,4 +16957,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
|
||||
);
|
||||
};
|
||||
exports.unstable_runWithPriority = runWithPriority;
|
||||
exports.version = "18.3.0-www-classic-a5b8c25c";
|
||||
exports.version = "18.3.0-www-classic-96d8b30d";
|
||||
|
||||
@@ -17463,7 +17463,7 @@ Internals.Events = [
|
||||
var devToolsConfig$jscomp$inline_1867 = {
|
||||
findFiberByHostInstance: getClosestInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-www-classic-7b25bc8c",
|
||||
version: "18.3.0-www-classic-f3aaf916",
|
||||
rendererPackageName: "react-dom"
|
||||
};
|
||||
(function (internals) {
|
||||
@@ -17507,7 +17507,7 @@ var devToolsConfig$jscomp$inline_1867 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-www-classic-7b25bc8c"
|
||||
reconcilerVersion: "18.3.0-www-classic-f3aaf916"
|
||||
});
|
||||
assign(Internals, {
|
||||
ReactBrowserEventEmitter: {
|
||||
@@ -17733,7 +17733,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
|
||||
);
|
||||
};
|
||||
exports.unstable_runWithPriority = runWithPriority;
|
||||
exports.version = "18.3.0-www-classic-7b25bc8c";
|
||||
exports.version = "18.3.0-www-classic-f3aaf916";
|
||||
|
||||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
||||
if (
|
||||
|
||||
@@ -67,9 +67,10 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
||||
break;
|
||||
}
|
||||
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({
|
||||
priority: postTaskPriority
|
||||
});
|
||||
var postTaskOptions = {
|
||||
priority: postTaskPriority,
|
||||
delay: typeof options === "object" && options !== null ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
@@ -96,9 +97,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
if (typeof result === "function") {
|
||||
// Assume this is a continuation
|
||||
var continuation = result;
|
||||
var continuationController = new TaskController();
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
});
|
||||
var continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
}; // Update the original callback node's controller, since even though we're
|
||||
// posting a new task, conceptually it's the same one.
|
||||
|
||||
@@ -67,9 +67,10 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
||||
break;
|
||||
}
|
||||
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({
|
||||
priority: postTaskPriority
|
||||
});
|
||||
var postTaskOptions = {
|
||||
priority: postTaskPriority,
|
||||
delay: typeof options === "object" && options !== null ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
@@ -96,9 +97,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
if (typeof result === "function") {
|
||||
// Assume this is a continuation
|
||||
var continuation = result;
|
||||
var continuationController = new TaskController();
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
});
|
||||
var continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
}; // Update the original callback node's controller, since even though we're
|
||||
// posting a new task, conceptually it's the same one.
|
||||
|
||||
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
currentPriorityLevel_DEPRECATED = priorityLevel;
|
||||
var result = callback(!1);
|
||||
if ("function" === typeof result) {
|
||||
var continuationController = new TaskController(),
|
||||
continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
};
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
}),
|
||||
continuationOptions = { signal: continuationController.signal };
|
||||
node._controller = continuationController;
|
||||
var nextTask = runTask.bind(
|
||||
null,
|
||||
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
|
||||
default:
|
||||
postTaskPriority = "user-visible";
|
||||
}
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({ priority: postTaskPriority });
|
||||
options = {
|
||||
priority: postTaskPriority,
|
||||
delay: "object" === typeof options && null !== options ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
|
||||
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
currentPriorityLevel_DEPRECATED = priorityLevel;
|
||||
var result = callback(!1);
|
||||
if ("function" === typeof result) {
|
||||
var continuationController = new TaskController(),
|
||||
continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
};
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
}),
|
||||
continuationOptions = { signal: continuationController.signal };
|
||||
node._controller = continuationController;
|
||||
var nextTask = runTask.bind(
|
||||
null,
|
||||
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
|
||||
default:
|
||||
postTaskPriority = "user-visible";
|
||||
}
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({ priority: postTaskPriority });
|
||||
options = {
|
||||
priority: postTaskPriority,
|
||||
delay: "object" === typeof options && null !== options ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
|
||||
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
currentPriorityLevel_DEPRECATED = priorityLevel;
|
||||
var result = callback(!1);
|
||||
if ("function" === typeof result) {
|
||||
var continuationController = new TaskController(),
|
||||
continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
};
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
}),
|
||||
continuationOptions = { signal: continuationController.signal };
|
||||
node._controller = continuationController;
|
||||
var nextTask = runTask.bind(
|
||||
null,
|
||||
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
|
||||
default:
|
||||
postTaskPriority = "user-visible";
|
||||
}
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({ priority: postTaskPriority });
|
||||
options = {
|
||||
priority: postTaskPriority,
|
||||
delay: "object" === typeof options && null !== options ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
|
||||
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
|
||||
currentPriorityLevel_DEPRECATED = priorityLevel;
|
||||
var result = callback(!1);
|
||||
if ("function" === typeof result) {
|
||||
var continuationController = new TaskController(),
|
||||
continuationOptions = {
|
||||
priority: postTaskPriority,
|
||||
signal: continuationController.signal
|
||||
};
|
||||
var continuationController = new TaskController({
|
||||
priority: postTaskPriority
|
||||
}),
|
||||
continuationOptions = { signal: continuationController.signal };
|
||||
node._controller = continuationController;
|
||||
var nextTask = runTask.bind(
|
||||
null,
|
||||
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
|
||||
default:
|
||||
postTaskPriority = "user-visible";
|
||||
}
|
||||
var controller = new TaskController();
|
||||
var controller = new TaskController({ priority: postTaskPriority });
|
||||
options = {
|
||||
priority: postTaskPriority,
|
||||
delay: "object" === typeof options && null !== options ? options.delay : 0,
|
||||
signal: controller.signal
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user