nriley / Pester

Simple, disposable alarms and timers for macOS.
https://sabi.net/nriley/software/#pester
BSD 2-Clause "Simplified" License
162 stars 14 forks source link

Avoid infinite loop due to not finding the default voice #20

Closed ssp closed 8 years ago

ssp commented 9 years ago

It seems that [NSSpeechSynthesizer defaultVoice] returns a voice ID which is not necessarily available in the list of voices returned by [NSSpeechSynthesizer availableVoices]. (It appears that installing the high quality voices results in voice IDs with ».premium« suffix in the list given by +availableVoices while +defaultVoice returns the original ID.)

This makes NJRVoicePopUpButton go into an infinite loop _refreshVoiceList → setVoice: → _invalidateSeletedVoice → _refreshVoiceList…

Short of understanding how to resolve this properly by avoiding an infinite loop for good, this patch tries to find a voice with the given ID and the suffix ».premium«.

Infinite loop and default voice name in the debugger: pester infinite loop

nriley commented 9 years ago

So sorry you're seeing this. The last few versions of Pester must have been crashing on launch for you then?

My attempt at emulating Apple's voice popup has been a disaster. It is infuriating that Apple refuses to make their voice menu available to third-party apps, as with the number of voices that have been added to OS X in previous versions, a plain menu is unusable. (Apple's own sample code uses an old API, which returns Pascal strings, and was written by someone who didn't get that Pascal strings aren't null-terminated).

Can you attach your com.apple.speech.voice.prefs file too, so I can test against something?

Thanks.

ssp commented 9 years ago

Hi Nicholas,

indeed Pester wasn’t working for me in the last few releases (although I think I managed to launch it successfully once after the 10.11 update). Interestingly I did not see crashes but the app icon just kept bouncing in the Dock. Inspecting this in the debugger suggests that you just get thousands and thousands of stack frames in this situation, perhaps I wasn’t patient enough to wait for the crash.

I attach the file (zipped since github refuses to accept plist files).

com.apple.speech.voice.prefs.plist.zip