Skip to content
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

Playing sound hangs the VM in Safari #286

Closed
dpinela opened this issue May 11, 2019 · 4 comments · Fixed by #287
Closed

Playing sound hangs the VM in Safari #286

dpinela opened this issue May 11, 2019 · 4 comments · Fixed by #287
Labels

Comments

@dpinela
Copy link

dpinela commented May 11, 2019

How to reproduce: Open the Windows 98 demo linked in the README. Open the WAV file in the desktop, or, alternatively, try to play a sound from the Sound control panel.

What should happen: Sound plays.

What happens: The VM hangs. The following error comes up in the console:

TypeError: e.copyToChannel is not a function. (In 'e.copyToChannel(a[0],0)', 'e.copyToChannel' is undefined)
ug — speaker.js:965
(anonymous function) — speaker.js:903
send — bus.js:77
Rd — sb16.js:1821
(anonymous function) — sb16.js:1741
(anonymous function) — dma.js:355
set — lib.js:119
Pe — dma.js:344
Sd — sb16.js:1747
(anonymous function) — sb16.js:232
send — bus.js:77
Gc — speaker.js:1009
(anonymous function) — speaker.js:909
send — bus.js:77
Fb — sb16.js:1737
Tc — dma.js:258
xh — dma.js:202
[native code]
cb — io.js:343
(anonymous function) — instructions.js:1211
we — cpu.js:1182
Ca — cpu.js:1113
ra — cpu.js:1099
jb — cpu.js:1085
(anonymous function) — main.js:108

The problem line in speaker.js:

        buffer.copyToChannel(data[0], 0);

Some research indicates that the problem is that Safari doesn't support the copyToChannel method on AudioBuffer.

Browser: Safari 12.1
OS: macOS 10.14.4

@copy copy added the bug label May 11, 2019
@ErnWong
Copy link
Contributor

ErnWong commented May 12, 2019

Thanks for reporting this! I'll look into getting sound working on safari. There seem to be other problems in addition to the one you found as well.

ErnWong added a commit to ErnWong/v86 that referenced this issue May 12, 2019
Fixes copy#286

Safari 12 does not support AudioBuffer#copyToChannel yet.
ErnWong added a commit to ErnWong/v86 that referenced this issue May 12, 2019
Fixes copy#286

Safari 12 does not support AudioBuffer#copyToChannel yet.
ErnWong added a commit to ErnWong/v86 that referenced this issue May 12, 2019
Fixes copy#286

Safari 12 does not support AudioBuffer#copyToChannel yet.
@ErnWong
Copy link
Contributor

ErnWong commented May 12, 2019

Here's a PR that fixes the copyToChannel bug.

I still couldn't get sound to work on my friend's iPad, but I couldn't get some kind of developer tools to connect to it yet to see what the problem is.

Hey @dpinela mind if I ask you to try out this PR and see if the sound file plays alright on your macOS?

@dpinela
Copy link
Author

dpinela commented May 13, 2019

Tried your PR. Now it no longer crashes, and it does try to play sound, but it's extremely choppy, to the point where most of the time you just don't hear anything.

Also, after playing sound (or trying to), it consistently gets into a state where some animations only update when you move the mouse, like opening a menu or minimising a window. This last part happens even in Chrome, where sound otherwise works fine (I wonder if it's actually a separate issue?)

@ErnWong
Copy link
Contributor

ErnWong commented May 14, 2019

...but it's extremely choppy...

Ah I see. I'll try and get hold of a mac to work on it one day, but that day probably won't be soon. (Pull requests from anyone are welcome!)

...some animations only update when you move the mouse...
...(I wonder if it's actually a separate issue?)

I originally thought it was a separate issue unrelated to audio, but I checked just now and it only enters this state after it starts playing audio, and it doesn't happen when I open Windows Media Player with v86's audio device disabled.

Well, it could also be a problem unrelated to audio, but which, wasn't revealed until audio was implemented and could be played by Windows Media Player. I have vague memories of seeing this behaviour outside of Windows Media Player when running v86 in debug mode, so it might be triggered by slow performance instead. (But this was from a year ago and I can't remember exactly if that was the case).

But whatever's causing it, yes I'll file this as a separate issue. Thanks for your help @dpinela !

@copy copy closed this as completed in #287 May 18, 2019
copy pushed a commit that referenced this issue May 18, 2019
Fixes #286

Safari 12 does not support AudioBuffer#copyToChannel yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants