-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio delays and performance issues in Safari on iOS/iPadOS #18
Comments
Looks like PR #2 from way back in the day would have addressed this, but was closed. I'll clean up and submit a new PR. |
I did a quick test of instantiating the sounds once, but upon testing I realized why it wasn't implemented that way: when typing quickly, the same sound will not be played for every key press as it may still/already be playing. It makes it sound/feel like it's not properly registering key presses. So, I think that migrating to the Web Audio API is probably the best bet. |
I have created an implementation using the Web Audio API and have tested in Chrome on desktop and Safari on iPadOS (14.x) and it completely resolves the stuttering audio & performance issues. There's some minor fallout, including:
It would be very easy to fall back to the Audio media element playback implementation if the newer browser support is an issue for anyone. I'll create a PR for review before I merge. Feedback is definitely welcome. |
Use Web Audio API to instantiate samples once and play performantly. Issue #18
PR #19 has been merged, so this should be all set. |
When used in Safari on iPadOS (14.x) with the Apple Magic Keyboard, the audio playback stutters and causes general performance issues.
Looking at
keyzen.js
, this may be due to the fact that theAudio
element is created, loaded, and then played every timekeyHandler()
orlevel_up()
is called (seekeyzen/keyzen.js
Line 95 in 9a75647
keyzen/keyzen.js
Line 101 in 9a75647
keyzen/keyzen.js
Line 132 in 9a75647
.wav
s on every instantiation ofAudio
.I'd suggest starting by instantiating the three
Audio
elements only once and re-using them. If that doesn't work, migrating to the Web Audio API would probably fix it as they all could be loaded under oneAudioContext
.The text was updated successfully, but these errors were encountered: