Skip to content

Refine Atomics.waitAsync polyfill conditions in libatomic.js - #28172

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:atomics_wait_async
Nov 5, 2026
Merged

sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:atomics_wait_async

Conversation

@sbc100

@sbc100 sbc100 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Only include the Atomics.waitAsync polyfill when targeting engines that lack support (Chrome < 91, Safari < 16.4, or Firefox < 145; Node.js has supported Atomics.waitAsync since v16.0.0).

Also guard the runtime Chrome < 91 user-agent regex check with #if MIN_CHROME_VERSION < 91 so it is omitted when targeting Chrome 91 or newer (such as the new default MIN_CHROME_VERSION=93 in #28141).

Only include the `Atomics.waitAsync` polyfill when targeting engines
that lack support (Chrome < 91, Safari < 16.4, or Firefox < 145; Node.js
has supported `Atomics.waitAsync` since v16.0.0).

Also guard the runtime Chrome < 91 user-agent regex check with
`#if MIN_CHROME_VERSION < 91` so it is omitted when targeting Chrome 91
or newer (such as the new default `MIN_CHROME_VERSION=93` in emscripten-core#28141).
@sbc100
sbc100 requested review from dschuff, juj and kripken November 4, 2026 22:49

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the polyfill logic for Atomics.waitAsync in src/lib/libatomic.js to better reflect browser support versions. The review identified an inaccuracy regarding the Firefox version, noting that support was added in version 87 rather than 145, and provided a code suggestion to correct the version check to avoid unnecessary polyfilling.

Comment thread src/lib/libatomic.js Resolved

@dschuff dschuff 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.

LGTM assuming code assist is wrong about the versions and you're right :)

@sbc100

sbc100 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

LGTM assuming code assist is wrong about the versions and you're right :)

I'm fairly sure my research (i.e. Gemini's research) is accurate.. and it matches canisuse.

@sbc100
sbc100 merged commit c829f0d into emscripten-core:main Nov 5, 2026
42 checks passed
@sbc100
sbc100 deleted the atomics_wait_async branch November 5, 2026 00:04
sbc100 added a commit to sbc100/emscripten that referenced this pull request Nov 5, 2026
Bump the default target browser versions in `src/settings.js`:
- `MIN_CHROME_VERSION`: 85 (Aug 2020) -> 93 (Aug 2021)
- `MIN_FIREFOX_VERSION`: 79 (Jul 2020) -> 92 (Sep 2021)
- `MIN_SAFARI_VERSION`: 150000 (Sep 2021) -> 150400 (Mar 2022)

This allows `$hasOwn` in `libcore.js` (introduced in emscripten-core#28129) to use the
`Object.hasOwn` fast path by default, and allows `$waitAsyncPolyfilled`
in `libatomic.js` (updated in emscripten-core#28172) to omit the Chrome < 91 user-agent
check by default.

Note: This does not effect the minimum browsers versions that we support
or the behaviour -sLEGACY_VM_SUPPORT.

See: emscripten-core#28125
sbc100 added a commit that referenced this pull request Nov 5, 2026
Bump the default target browser versions in `src/settings.js`:
- `MIN_CHROME_VERSION`: 85 (Aug 2020) -> 93 (Aug 2021)
- `MIN_FIREFOX_VERSION`: 79 (Jul 2020) -> 92 (Sep 2021)
- `MIN_SAFARI_VERSION`: 150000 (Sep 2021) -> 150400 (Mar 2022)

This allows `$hasOwn` in `libcore.js` (introduced in #28129) to use the
`Object.hasOwn` fast path by default, and allows `$waitAsyncPolyfilled`
in `libatomic.js` (updated in #28172) to omit the Chrome < 91 user-agent
check by default.

Note: This does not effect the minimum browsers versions that we support
or the behaviour -sLEGACY_VM_SUPPORT.

See: #28125
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.

2 participants