Skip to content

Cleanup legacy browser support in libopenal.js. NFC - #27435

Closed
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:openal_webkitAudioContext
Closed

Cleanup legacy browser support in libopenal.js. NFC#27435
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:openal_webkitAudioContext

Conversation

@sbc100

@sbc100 sbc100 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This brings libopenal.js inline with libwebaudio.js in a couple of ways:

  • Only support webkitAudioContext on older safari versions.
  • Drop support for new AudioContext that does not accept options.

This change should make is easy for us to remove this support once we drop support for Safari < 14.5.

@sbc100
sbc100 requested a review from kripken July 28, 2026 18:01
@sbc100
sbc100 force-pushed the openal_webkitAudioContext branch from 1bb7d7d to 6944cd8 Compare July 28, 2026 18:06
Comment thread src/lib/libopenal.js
Comment thread src/lib/libopenal.js Outdated

var AudioContext = window.AudioContext || window.webkitAudioContext;
#if MIN_SAFARI_VERSION < 140500
var AudioContext = window.AudioContext ?? window.webkitAudioContext;

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.

Why does this read window, and above we read globalThis?

@sbc100 sbc100 Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Using globalThis in hasAudioContext avoid crash on startup on node (or other places where window does not exist). If could use window there too and make it include a function instead of a property if you prefer?

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.

Wait, why would it be good to use window there too? I would expect to use globalThis in all places, as the most supported? (node, workers, etc.)

Also, can we merge these two places together? Instead of a hasAudioContext property it could be AudioContext, and then we can just use it from there?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason I think its OK to use the window. for the usage path is that we expect that code to crash if its missing.

It doesn't really matter if its undefined window object or undefined window.AudioContext contructor, its still the same crash.

The reason I don't really want to merge these is that I want the usage path in the default case to look like new AudioContext().. not new getAudioContext().. it seems cleaner. Maybe I can keep that though .. let me try it.

Comment thread src/lib/libopenal.js
@sbc100
sbc100 force-pushed the openal_webkitAudioContext branch 3 times, most recently from 03584b4 to c4c7cf3 Compare July 29, 2026 21:40
@sbc100
sbc100 requested a review from kripken July 29, 2026 21:41
@sbc100

sbc100 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

I found a way to unify so this fallback was only specified in once place.

Comment thread src/lib/libopenal.js Outdated
This brings libopenal.js inline with libwebaudio.js in a couple
of ways:

- Only support webkitAudioContext on older safari versions.
- Drop support for `new AudioContext` that does not accept options.

This change should make is easy for us to remove this support
once we drop support for Safari < 14.5.
@sbc100
sbc100 force-pushed the openal_webkitAudioContext branch from c4c7cf3 to 4a5f24f Compare July 30, 2026 00:36
@sbc100
sbc100 enabled auto-merge (squash) July 30, 2026 00:37
@sbc100

sbc100 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

I'm going abandon this in favor of #27444

@sbc100 sbc100 closed this Jul 30, 2026
auto-merge was automatically disabled July 30, 2026 00:55

Pull request was closed

@sbc100
sbc100 deleted the openal_webkitAudioContext branch July 30, 2026 00:55
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