Skip to content

Commit 5a211bb

Browse files
committed
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 [4129ea8](4129ea8)
1 parent eeb3579 commit 5a211bb

10 files changed

+40
-44
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
456d153bb582798effa76c09bec2405ab2e392cf
1+
4129ea8c922b950be3964f98d2bb74ff4a1c5431

compiled/facebook-www/ReactDOM-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34000,7 +34000,7 @@ function createFiberRoot(
3400034000
return root;
3400134001
}
3400234002

34003-
var ReactVersion = "18.3.0-www-classic-72a2d0d7";
34003+
var ReactVersion = "18.3.0-www-classic-d49923a6";
3400434004

3400534005
function createPortal$1(
3400634006
children,

compiled/facebook-www/ReactDOM-prod.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16688,7 +16688,7 @@ Internals.Events = [
1668816688
var devToolsConfig$jscomp$inline_1782 = {
1668916689
findFiberByHostInstance: getClosestInstanceFromNode,
1669016690
bundleType: 0,
16691-
version: "18.3.0-www-classic-a5b8c25c",
16691+
version: "18.3.0-www-classic-96d8b30d",
1669216692
rendererPackageName: "react-dom"
1669316693
};
1669416694
var internals$jscomp$inline_2139 = {
@@ -16718,7 +16718,7 @@ var internals$jscomp$inline_2139 = {
1671816718
scheduleRoot: null,
1671916719
setRefreshHandler: null,
1672016720
getCurrentFiber: null,
16721-
reconcilerVersion: "18.3.0-www-classic-a5b8c25c"
16721+
reconcilerVersion: "18.3.0-www-classic-96d8b30d"
1672216722
};
1672316723
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1672416724
var hook$jscomp$inline_2140 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16957,4 +16957,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
1695716957
);
1695816958
};
1695916959
exports.unstable_runWithPriority = runWithPriority;
16960-
exports.version = "18.3.0-www-classic-a5b8c25c";
16960+
exports.version = "18.3.0-www-classic-96d8b30d";

compiled/facebook-www/ReactDOM-profiling.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17463,7 +17463,7 @@ Internals.Events = [
1746317463
var devToolsConfig$jscomp$inline_1867 = {
1746417464
findFiberByHostInstance: getClosestInstanceFromNode,
1746517465
bundleType: 0,
17466-
version: "18.3.0-www-classic-7b25bc8c",
17466+
version: "18.3.0-www-classic-f3aaf916",
1746717467
rendererPackageName: "react-dom"
1746817468
};
1746917469
(function (internals) {
@@ -17507,7 +17507,7 @@ var devToolsConfig$jscomp$inline_1867 = {
1750717507
scheduleRoot: null,
1750817508
setRefreshHandler: null,
1750917509
getCurrentFiber: null,
17510-
reconcilerVersion: "18.3.0-www-classic-7b25bc8c"
17510+
reconcilerVersion: "18.3.0-www-classic-f3aaf916"
1751117511
});
1751217512
assign(Internals, {
1751317513
ReactBrowserEventEmitter: {
@@ -17733,7 +17733,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
1773317733
);
1773417734
};
1773517735
exports.unstable_runWithPriority = runWithPriority;
17736-
exports.version = "18.3.0-www-classic-7b25bc8c";
17736+
exports.version = "18.3.0-www-classic-f3aaf916";
1773717737

1773817738
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
1773917739
if (

compiled/facebook-www/SchedulerPostTask-dev.classic.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
6767
break;
6868
}
6969

70-
var controller = new TaskController();
70+
var controller = new TaskController({
71+
priority: postTaskPriority
72+
});
7173
var postTaskOptions = {
72-
priority: postTaskPriority,
7374
delay: typeof options === "object" && options !== null ? options.delay : 0,
7475
signal: controller.signal
7576
};
@@ -96,9 +97,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
9697
if (typeof result === "function") {
9798
// Assume this is a continuation
9899
var continuation = result;
99-
var continuationController = new TaskController();
100+
var continuationController = new TaskController({
101+
priority: postTaskPriority
102+
});
100103
var continuationOptions = {
101-
priority: postTaskPriority,
102104
signal: continuationController.signal
103105
}; // Update the original callback node's controller, since even though we're
104106
// posting a new task, conceptually it's the same one.

compiled/facebook-www/SchedulerPostTask-dev.modern.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
6767
break;
6868
}
6969

70-
var controller = new TaskController();
70+
var controller = new TaskController({
71+
priority: postTaskPriority
72+
});
7173
var postTaskOptions = {
72-
priority: postTaskPriority,
7374
delay: typeof options === "object" && options !== null ? options.delay : 0,
7475
signal: controller.signal
7576
};
@@ -96,9 +97,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
9697
if (typeof result === "function") {
9798
// Assume this is a continuation
9899
var continuation = result;
99-
var continuationController = new TaskController();
100+
var continuationController = new TaskController({
101+
priority: postTaskPriority
102+
});
100103
var continuationOptions = {
101-
priority: postTaskPriority,
102104
signal: continuationController.signal
103105
}; // Update the original callback node's controller, since even though we're
104106
// posting a new task, conceptually it's the same one.

compiled/facebook-www/SchedulerPostTask-prod.classic.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
2323
currentPriorityLevel_DEPRECATED = priorityLevel;
2424
var result = callback(!1);
2525
if ("function" === typeof result) {
26-
var continuationController = new TaskController(),
27-
continuationOptions = {
28-
priority: postTaskPriority,
29-
signal: continuationController.signal
30-
};
26+
var continuationController = new TaskController({
27+
priority: postTaskPriority
28+
}),
29+
continuationOptions = { signal: continuationController.signal };
3130
node._controller = continuationController;
3231
var nextTask = runTask.bind(
3332
null,
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
121120
default:
122121
postTaskPriority = "user-visible";
123122
}
124-
var controller = new TaskController();
123+
var controller = new TaskController({ priority: postTaskPriority });
125124
options = {
126-
priority: postTaskPriority,
127125
delay: "object" === typeof options && null !== options ? options.delay : 0,
128126
signal: controller.signal
129127
};

compiled/facebook-www/SchedulerPostTask-prod.modern.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
2323
currentPriorityLevel_DEPRECATED = priorityLevel;
2424
var result = callback(!1);
2525
if ("function" === typeof result) {
26-
var continuationController = new TaskController(),
27-
continuationOptions = {
28-
priority: postTaskPriority,
29-
signal: continuationController.signal
30-
};
26+
var continuationController = new TaskController({
27+
priority: postTaskPriority
28+
}),
29+
continuationOptions = { signal: continuationController.signal };
3130
node._controller = continuationController;
3231
var nextTask = runTask.bind(
3332
null,
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
121120
default:
122121
postTaskPriority = "user-visible";
123122
}
124-
var controller = new TaskController();
123+
var controller = new TaskController({ priority: postTaskPriority });
125124
options = {
126-
priority: postTaskPriority,
127125
delay: "object" === typeof options && null !== options ? options.delay : 0,
128126
signal: controller.signal
129127
};

compiled/facebook-www/SchedulerPostTask-profiling.classic.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
2323
currentPriorityLevel_DEPRECATED = priorityLevel;
2424
var result = callback(!1);
2525
if ("function" === typeof result) {
26-
var continuationController = new TaskController(),
27-
continuationOptions = {
28-
priority: postTaskPriority,
29-
signal: continuationController.signal
30-
};
26+
var continuationController = new TaskController({
27+
priority: postTaskPriority
28+
}),
29+
continuationOptions = { signal: continuationController.signal };
3130
node._controller = continuationController;
3231
var nextTask = runTask.bind(
3332
null,
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
121120
default:
122121
postTaskPriority = "user-visible";
123122
}
124-
var controller = new TaskController();
123+
var controller = new TaskController({ priority: postTaskPriority });
125124
options = {
126-
priority: postTaskPriority,
127125
delay: "object" === typeof options && null !== options ? options.delay : 0,
128126
signal: controller.signal
129127
};

compiled/facebook-www/SchedulerPostTask-profiling.modern.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
2323
currentPriorityLevel_DEPRECATED = priorityLevel;
2424
var result = callback(!1);
2525
if ("function" === typeof result) {
26-
var continuationController = new TaskController(),
27-
continuationOptions = {
28-
priority: postTaskPriority,
29-
signal: continuationController.signal
30-
};
26+
var continuationController = new TaskController({
27+
priority: postTaskPriority
28+
}),
29+
continuationOptions = { signal: continuationController.signal };
3130
node._controller = continuationController;
3231
var nextTask = runTask.bind(
3332
null,
@@ -121,9 +120,8 @@ exports.unstable_scheduleCallback = function (
121120
default:
122121
postTaskPriority = "user-visible";
123122
}
124-
var controller = new TaskController();
123+
var controller = new TaskController({ priority: postTaskPriority });
125124
options = {
126-
priority: postTaskPriority,
127125
delay: "object" === typeof options && null !== options ? options.delay : 0,
128126
signal: controller.signal
129127
};

0 commit comments

Comments
 (0)