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.
Jason Miller committed
Nov 16, 2018 at 10:39 UTC
a22fabc2a110a40ead576ada5b3bf66840e852ba
1 file changed
+2
-2
packages/scheduler/src/Scheduler.js
+2
-2
@@ -618,7 +618,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
618
frameDeadline = rafTime + activeFrameTime;
619
if (!isMessageEventScheduled) {
620
isMessageEventScheduled = true;
621
- port.postMessage('*');
621
+ port.postMessage(undefined);
622
}
623
};
624
@@ -627,7 +627,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
627
timeoutTime = absoluteTimeout;
628
if (isFlushingHostCallback || absoluteTimeout < 0) {
629
// Don't wait for the next frame. Continue working ASAP, in a new event.
630
- port.postMessage('*');
630
+ port.postMessage(undefined);
631
} else if (!isAnimationFrameScheduled) {
632
// If rAF didn't already schedule one, we need to schedule a frame.
633
// TODO: If this rAF doesn't materialize because the browser throttles, we