Skip to content

Commit

Permalink
Reduce scheduler serialization overhead (facebook#14249)
Browse files Browse the repository at this point in the history
In the process of switching to MessageChannel, it seems the postMessage call was modified to pass `"*"` (originally the target origin value from `window.postMessage`). This actually ends up triggering serialization, whereas passing `undefined` bypasses.

To save some investigation, passing a Number like `0` still incurs serialization overhead - `undefined` has special behavior.
  • Loading branch information
developit authored and n8schloss committed Jan 31, 2019
1 parent 9ffc465 commit 1193c44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/scheduler/src/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
frameDeadline = rafTime + activeFrameTime;
if (!isMessageEventScheduled) {
isMessageEventScheduled = true;
port.postMessage('*');
port.postMessage(undefined);
}
};

Expand All @@ -627,7 +627,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
timeoutTime = absoluteTimeout;
if (isFlushingHostCallback || absoluteTimeout < 0) {
// Don't wait for the next frame. Continue working ASAP, in a new event.
port.postMessage('*');
port.postMessage(undefined);
} else if (!isAnimationFrameScheduled) {
// If rAF didn't already schedule one, we need to schedule a frame.
// TODO: If this rAF doesn't materialize because the browser throttles, we
Expand Down

0 comments on commit 1193c44

Please sign in to comment.