phetsims / resistance-in-a-wire

"Resistance in a Wire" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/resistance-in-a-wire
GNU General Public License v3.0
1 stars 4 forks source link

Sound Disappears when two tabs are open in landscape #199

Closed KatieWoe closed 5 years ago

KatieWoe commented 5 years ago

Device iPad OS iOS 9 and 11 at least Browser Safari Problem Description For https://github.com/phetsims/QA/issues/219. Found by @jbphet on iOS 9 device. When two tabs of resistance in a wire are open and one plays sound this disables the other tab's sound. This only occurs if the tabs have been in landscape mode. In portrait this does not occur. I did not reproduce this on Mac OS safari. The published version of John Travoltage did not seem to exhibit this behavior. Steps to reproduce

  1. Make sure iPad is in portrait mode and keep there until instructed
  2. Open the sim
  3. Open a second tab and open the sim there
  4. Play with sliders on first tab
  5. Play with sliders on second tab
  6. Play with slider on first tab again
  7. Switch to landscape
  8. Play with sliders on first tab
  9. Play with sliders on second tab
  10. Play with slider on first tab again
jbphet commented 5 years ago

I just ran a test with some debug code and found that the audio context is being placed in the "interrupted" state in this case. This is also what we saw sometimes when going into full screen mode in Safari, see https://github.com/phetsims/resistance-in-a-wire/issues/190.

jbphet commented 5 years ago

Since this problem was occurring on mobile Safari, I wanted to make sure that it wasn't happening on the non-mobile version. I tested on PhET's MacBook Pro "Dirac" running 10.11.6 "El Capitan" and Safari version 11.1.2, and the problem did not occur. In other words, I could switch between tabs, play sound on both, and it continued to work on both.

jbphet commented 5 years ago

The title of this issue is a little misleading. The problem only occurs if you open a sonified sim in both tabs. Specifically (and these sequences were done on the iPad 2 "Tycho"), if I open RIAW in one tab and then open a 2nd tab and go to Google, then switch back to the original RIAW screen, sound still works fine. I also tested the same scenario but instead of Google I opened a non-sonified PhET sim (acid-base-solutions in this case), and again, sound worked fine upon returning to the RIAW tab. However, when I loaded the currently published version of John Travoltage in the 2nd tab, sound was gone when returning to the RIAW tab. It would seem the using sound in a 2nd tab is what kills it for the first.

jbphet commented 5 years ago

I've added code that resumes the audio context if it is in the "interrupted" state when the sim becomes visible after being made not visible. This seems to improve the situation quite a bit, though I could still make the audio go away on iOS 11 after a lot of switching between tabs.

I'm going to call this fixed because I believe it fixes the scenario described in https://github.com/phetsims/resistance-in-a-wire/issues/199#issue-384503266, because lots of tab switching between sound-generating sims is probably a fairly rare use case, because a reload fixes the issue, and because I'm not sure there's much else we could do.

jbphet commented 5 years ago

Fixed (more or less) in 1.6.0-rc.2, unassigning while we await the results of the RC test.

KatieWoe commented 5 years ago

I had this happen once in rc.2 though I haven't gotten it to happen again. iOS 12. @jbphet

jbphet commented 5 years ago

I think it's reasonable to close this at this point.