Skip to content

Conversation

@Mimori256
Copy link
Contributor

This PR replaces Promise.resolve().then(){ with queueMicrotask()when scheduling thePerformanceObserver` callback.

This change makes the intention of microtask queuing clear and documents the Safari workaround, and also reduces the overhead of creating unnecessary promises.

queueMicrotask() is part of the Baseline widely available set, so this change should not introduce any new browser compatibility issues.

Replace `Promise.resolve().then()` with `queueMicrotask()` for more
explicit and efficient microtask scheduling
Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

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

Sorry missed this. I think this is OK and better practice, even if functionally equivalent.

@philipwalton any opinions?

@philipwalton
Copy link
Member

I'm fine with this change, given this project now supports Baseline widely available.

I guess a separate question is whether or not this line is even still needed...

@tunetheweb
Copy link
Member

I guess a separate question is whether or not this line is even still needed...

Oh seems uncertain the underlying bug is fixed reading https://bugs.webkit.org/show_bug.cgi?id=247863 ? And, if so, when it was fixed. I guess to be safe we should wait 30 months?

Anyway, let's merge this for now.

@tunetheweb tunetheweb merged commit 82d0326 into GoogleChrome:main Dec 16, 2025
6 checks passed
@philipwalton
Copy link
Member

Oh seems uncertain the underlying bug is fixed reading https://bugs.webkit.org/show_bug.cgi?id=247863 ? And, if so, when it was fixed. I guess to be safe we should wait 30 months?

Yeah, I just tried and I'm still seeing the bug in Safari, though it does appear to be fixed in Safari Tech Preview. But I agreed that we'll need to wait a while to remove this. (#277)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants