@samitouri / QOS-React / commits / c1cca0c7d8

Don't need to keep track of rootsWithUncaughtErrors

Just give it NoWork priority and findNextUnitOfWork will handle the rest

Andrew Clark committed Nov 4, 2016 at 17:58 UTC c1cca0c7d8e0cad2e4dfb88cdd3a095b8acc1c51
1 file changed +6 -15
src/renderers/shared/fiber/ReactFiberScheduler.js
+6 -15
@@ -101,9 +101,6 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
101 let activeErrorBoundaries : Set<Fiber> | null = null;
102 let nextTrappedErrors : Array<TrappedError> | null = null;
103
104 - // Roots that have uncaught errors and should not be worked on
105 - let rootsWithUncaughtErrors : Set<FiberRoot> | null = null;
106 -
104 function scheduleAnimationCallback(callback) {
105 if (!isAnimationCallbackScheduled) {
106 isAnimationCallbackScheduled = true;
@@ -120,10 +117,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
117
118 function findNextUnitOfWork() {
119 // Clear out roots with no more work on them, or if they have uncaught errors
123 - while (nextScheduledRoot && (
124 - nextScheduledRoot.current.pendingWorkPriority === NoWork ||
125 - (rootsWithUncaughtErrors && rootsWithUncaughtErrors.has(nextScheduledRoot))
126 - )) {
120 + while (nextScheduledRoot && nextScheduledRoot.current.pendingWorkPriority === NoWork) {
121 // Unschedule this root.
122 nextScheduledRoot.isScheduled = false;
123 // Read the next pointer now.
@@ -544,8 +538,6 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
538 activeErrorBoundaries = new Set();
539 // If we find unhandled errors, we'll only remember the first one.
540 let firstUncaughtError = null;
547 - // Keep track of which roots have fataled and need to be unscheduled.
548 - rootsWithUncaughtErrors = new Set();
541
542 // All work created by error boundaries should have Task priority
543 // so that it finishes before this function exits.
@@ -563,11 +555,11 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
555 const root = trappedError.root;
556 if (!boundary) {
557 firstUncaughtError = firstUncaughtError || error;
566 - if (root) {
567 - // Remember to unschedule this particular root since it fataled
568 - // and we can't do more work on it. This lets us continue working on
569 - // other roots even if one of them fails before rethrowing the error.
570 - rootsWithUncaughtErrors.add(root);
558 + if (root && root.current) {
559 + // Unschedule this particular root since it fataled and we can't do
560 + // more work on it. This lets us continue working on other roots
561 + // even if one of them fails before rethrowing the error.
562 + root.current.pendingWorkPriority = NoWork;
563 } else {
564 // Normally we should know which root caused the error, so it is
565 // unusual if we end up here. Since we assume this function always
@@ -615,7 +607,6 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
607
608 nextTrappedErrors = null;
609 activeErrorBoundaries = null;
618 - rootsWithUncaughtErrors = null;
610 priorityContext = previousPriorityContext;
611
612 // Return the error so we can rethrow after handling other roots.