Skip to content

Commit a22fabc

Browse files
developitacdlite
authored andcommitted
Reduce scheduler serialization overhead (#14249)
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.
1 parent 21d5f7d commit a22fabc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/scheduler/src/Scheduler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
618618
frameDeadline = rafTime + activeFrameTime;
619619
if (!isMessageEventScheduled) {
620620
isMessageEventScheduled = true;
621-
port.postMessage('*');
621+
port.postMessage(undefined);
622622
}
623623
};
624624

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

0 commit comments

Comments
 (0)