Skip to content

Use MessageChannel instead of setTimeout to avoid processing delays - #8673

Merged
mourner merged 2 commits into
masterfrom
messagechannel
Aug 22, 2019
Merged

mourner merged 2 commits into
masterfrom
messagechannel

Conversation

@kkaefer

@kkaefer kkaefer commented Aug 22, 2019

Copy link
Copy Markdown
Member

Fixes #8671.

It works around the setTimeout caveats in IE (in my analysis, I found that setTimeout sometimes took more than 30 milliseconds just to execute the next call!) by switch to the universally supported MessageChannel objects. It's normally used to communicate between two different contexts, but you can also use it to "communicate" between the same context. It solves the performance regression reported in #8671 while maintaining the faster cancellation processing from #8633 by decoupling the messages sent from the counterpart from processing: it throttles the postMessage calls it receives from the sender to just one pending postMessage. This is essentially what setTimeout(..., 0) does too.

@kkaefer
kkaefer requested review from ahk, arindam1993 and mourner August 22, 2019 09:02
@kkaefer kkaefer self-assigned this Aug 22, 2019
@kkaefer kkaefer added this to the release-queso milestone Aug 22, 2019
@kkaefer kkaefer added the skip changelog Used for PRs that do not need a changelog entry label Aug 22, 2019

@mourner mourner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the builds ran, looks like we need a MessageChannel fallback for Node.

also adds a fallback for environments that don't support MessageChannel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 release blocker ⛔ skip changelog Used for PRs that do not need a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

release-queso: Performance regression in "Animate a point" example

2 participants