-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[scheduler] Post to MessageChannel instead of window #14234
Conversation
Scheduler needs to schedule a task that fires after paint. To do this, it currently posts a message event to `window`. This happens on every frame until the queue is empty. An unfortunate consequence is that every other message event handler also gets called on every frame; even if they exit immediately, this adds up to significant per-frame overhead. Instead, we'll create a MessageChannel and post to that, with a fallback to the old behavior if MessageChannel does not exist.
1736f33
to
9126e21
Compare
React: size: 🔺+0.9%, gzip: 🔺+0.9% Details of bundled changes.Comparing: d7fd679...9126e21 react
scheduler
Generated by 🚫 dangerJS |
@@ -533,13 +533,14 @@ if (typeof window !== 'undefined' && window._schedMock) { | |||
}; | |||
|
|||
// We use the postMessage trick to defer idle work until after the repaint. | |||
var port = null; | |||
var messageKey = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overhead of this is no longer necessary in this mechanism since it's a unique channel.
} else { | ||
// Otherwise post a message to the window. This isn't ideal because message | ||
// handlers will fire on every frame until the queue is empty, including | ||
// some browser extensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this fallback? IE9? Do we even support that anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk, for some reason I thought FB did but I guess we don't any longer
Maybe just fallback to |
Scheduler needs to schedule a task that fires after paint. To do this, it currently posts a message event to `window`. This happens on every frame until the queue is empty. An unfortunate consequence is that every other message event handler also gets called on every frame; even if they exit immediately, this adds up to significant per-frame overhead. Instead, we'll create a MessageChannel and post to that, with a fallback to the old behavior if MessageChannel does not exist.
Scheduler needs to schedule a task that fires after paint. To do this, it currently posts a message event to `window`. This happens on every frame until the queue is empty. An unfortunate consequence is that every other message event handler also gets called on every frame; even if they exit immediately, this adds up to significant per-frame overhead. Instead, we'll create a MessageChannel and post to that, with a fallback to the old behavior if MessageChannel does not exist.
Scheduler needs to schedule a task that fires after paint. To do this, it currently posts a message event to
window
. This happens on every frame until the queue is empty. An unfortunate consequence is that every other message event handler also gets called on every frame; even if they exit immediately, this adds up to significant per-frame overhead.Instead, we'll create a MessageChannel and post to that, with a fallback to the old behavior if MessageChannel does not exist.