Cleanup legacy browser support in libopenal.js. NFC - #27435
Conversation
1bb7d7d to
6944cd8
Compare
|
|
||
| var AudioContext = window.AudioContext || window.webkitAudioContext; | ||
| #if MIN_SAFARI_VERSION < 140500 | ||
| var AudioContext = window.AudioContext ?? window.webkitAudioContext; |
There was a problem hiding this comment.
Why does this read window, and above we read globalThis?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
03584b4 to
c4c7cf3
Compare
|
I found a way to unify so this fallback was only specified in once place. |
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.
c4c7cf3 to
4a5f24f
Compare
|
I'm going abandon this in favor of #27444 |
This brings libopenal.js inline with libwebaudio.js in a couple of ways:
new AudioContextthat does not accept options.This change should make is easy for us to remove this support once we drop support for Safari < 14.5.