Closed jessegreenberg closed 3 years ago
Just played with the sim for ~10 minutes to see if it happens at a particular time, and got it to occur twice. The first time it when I read the first reading block. The second time was 10 minutes later when electrons were discharged.
To try lots of speech requests I did something like this, where I added the ResetAllButton to the window and then did
window.setInterval( () => {
window.resetAllButton.buttonModel.fire()
), 300 ).
Every 300 ms I hear "Reset..." Then it gets interrupted by the next "Reset". Up to 500 requests and no crash.
I had the sim fuzz for three minutes without Voicing, so I think that confirms that Voicing is the cause.
OK, I found a way to get it to crash relatively consistently - spam the Toolbar chevron button with spacebar presses to rapidly open and close the toolbar.
Adding the chevron button to the window and spamming it with
var i = 0;
setInterval( () => {
console.log( i++ )
window.testButton.buttonModel.fire()
}, 200 )
Gets it to crash in 2 - 80 fires.
Now that I can get it to happen easily, I am going to try to find what is causing the crash to see if we can prevent it.
this.synth.cancel()
with this.synth.pause()
and this.synth.resume()
to see if that would change something. Didn't work.this.synth.cancel()
entirely from webSpeaker.speak and after 107 speech requests it crashed.this.synth.cancel()
and removed this.utterances.push( speechSynthesisUtterance )
(a Safari Workaround for an issue where the utterance end
event never fired). Still crashed.click
on the ResetAllButton PDOM element instead of calling fire
on the button model. Hearing continuous Voicing + Sound I am at almost 1000 presses with no crash.
window.setInterval( () => {
window.speechSynthesis.cancel();
window.speechSynthesis.speak( new SpeechSynthesisUtterance( 'Hello there, this is a test' ) )
}, 300 )
This testing was done on a MacBook Pro (2013) with macOS 11.2 Big Sur.
EDIT: I upgraded to 11.4 Big sur and I am no longer seeing crashes when running the test at https://github.com/phetsims/john-travoltage/issues/422#issuecomment-849182011 with the Toolbar button. Currently at 700 presses.
I read about web workers to offload the speech, but the window and speechSynthesis
are not available in a web worker, so we can't do that.
I am not sure how to proceed, I can't think of a workaround and I don't see a good solution. Other things I considered. 1) Stop simulation motion during speech. Seems like it would make a terrible experience. 2) We submit a bug report to Firefox about speechSynthesis crashing the browser. Hopefully we can get this to happen in an example outside of PhET. 3) We disable Voicing in macOS Firefox.
As of right now, I am afraid we must do at least 3.
@terracoda said on slack that she uses macOS and Firefox. @terracoda would you mind testing to see if this happens for you?
@KatieWoe would you also be able to try this on macOS Firefox to see if it ever crashes for you? That might help us determine how far we need to go here.
I can get it to most consistently crash by pressing the Toolbar's Open/Close button. But also seeing it crash sometimes when charges are being added/removed from the body.
Link to latest: https://phet-dev.colorado.edu/html/john-travoltage/1.6.0-preferences.12/phet/john-travoltage_en_phet.html
Using MacOS 10.13.6 and Firefox 88.0.1 (64-bit) I used JT with mouse and keyboard and tried to do several things really fast:
I didn't experience any crashes. And I haven't rebooted for a few days either.
I played around for a bit (5-10 min) on MacOS 11.4 Firefox 88.0.1 and didn't see a crash. @jessegreenberg let me know if you want me to look at an older OS or test on 11.4 for longer.
Thanks for testing @KatieWoe that is good news. I think this issue is related to performance and the crash happens for me during high cpu load. I have a MacBook from 2013 with 2.4 GHz dual-core i5 processor. Would you mind noting the specs of your apple device for comparison?
MacBook Pro 2016. 2.9 GHz Quad-Core Intel Core i7.
Cool, thanks. @terracoda would you mind noting the same info from your machine?
Thanks, that is helpful. Both of those devices are newer/faster than the one I have. Over slack I asked if @KatieWoe had access to an older/slower mac and she said yes, so I asked her to check if there was any crashing there.
@terracoda also mentioned she had access to a slower/older device and volunteered to test it there to see if it happens.
Oldest readily available Mac is a MacBook Pro 2011, 2.3 GHz intel Core i5. I need to give it a bit to charge up, then will test to see if the firefox problem can be reproduced with it. Will test on OS 10.12.
On terracoda's Macbook Air - no crashing
FF version - 88.0.1 (64-bit)
I didn't get it to crash on the older device, but it definitely had to work hard and the fan was getting pretty noisy.
On terracoda's old Macbook Pro - no crashing
Testing on Firefox
OK thanks @KatieWoe and @terracoda. @BLFiedler also mentioned today that he will keep an eye out for whether this is prevalent in the survey he puts out.
So to summarize, it sounds like the crashing is rare, but we have now seen it on two devices with older CPUs. I still think it is caused by how much work is being done by the browser and/or how what the CPU load is and that explains why @terracoda saw it intermittently on that old device. Ultimately, I think there is a risk that this will happen in the wild for those that are using older macOS devices with Firefox, so it would be good to discuss the implications of this with others on the team.
In comments in this issue I documented attempts to fix the crashing but didn't find any sort of workaround. @emily-phet @terracoda @BLFiedler can we discuss how to proceed?
Just to be sure, I also just tested on a new MacBook Air (M1, 2020)
Firefox version 88.0.1 (64-bit)
No crashing. No issues.
@jessegreenberg, I think it is worth a bug report to Mozilla, for sure. We have some quite specific data re OS versions, CPUs and FF version that could be helpful. In my case, the crashing was very consistent on the version 77 and there was no crashing on the other versions.
I don't think we should disable Voicing on Firefox on MacOs. That seems too drastic to me.
Over Slack, @terracoda agreed to try a test on her Firefox machine to see if we can get it to crash like my mac even with the latest Firefox.
Here is a link to the version: https://phet-dev.colorado.edu/html/john-travoltage/1.6.0-preferences.14/phet/john-travoltage_en_phet.html
It has a function on the window that can be called from window.startTest()
from the console, which will spam the Toolbar open button with presses.
@jessegreenberg showed me how to window.StartTest() on my old mac (https://github.com/phetsims/john-travoltage/issues/422#issuecomment-850639220). The Toolbar was opened and closed 3300 times without a crash.
Version tested: john-travoltage/1.6.0-preferences.14
I will test on iPad and iMac, too, as soon as possible and report back here.
Testing today on iMac Retina 4k, 21.5-inch, 2019
iPad (6th generation) model MRM52LL/A
@jessegreenberg, I have exhausted my mac devices.
As I said in https://github.com/phetsims/john-travoltage/issues/422#issuecomment-850728600 , a bug report may be the way to go.
I feel confident we don't have to restrict Voicing to certain browsers or platforms.
From my point of a view an update from version 77 to 78 solved the crashing problem on my old Mac and I didn't experience any issues on other systems I tested on.
I unassigned myself. Let me know if there is anything else needed fro this issue.
We discussed this issue and how to proceed in the Voicing meeting today. We all felt that the crashing issue seems rare enough that we can proceed with a bug report and no browser or device restrictions for the Voicing feature when we are ready to publish our first sim with Voicing.
I am going to mark this issue as won't fix, and make a new issue to create the bug report. I hope that is a reasonable path forward.
Maybe we don't need a new issue for the bug report? @jessegreenberg, can you close this issue when you have created a bug report to Firefox about speechSynthesis crashing the browser.
Or let me know how to create a bug report :-) Thanks for all your hard work on this issue.
Sounds good @terracoda, thanks! I just submitted a bug report for this with the details from my crash on the device where it happened. Closing this issue then.
Found while testing for #419, in macOS + Firefox the the browser crashes frequently when the Voicing feature is enabled. Basic speech works ok https://mdn.github.io/web-speech-api/speak-easy-synthesis/, so something about way we are using the feature is causing the crash.