+[NSSpeechSynthesizer attributesForVoice:] consumes 2MB+ of memory on macOS. |
||||
Issue descriptionI've been looking at sources of browser memory bloat by using native heap profiling on my own browser. Full details: https://docs.google.com/document/d/1fN5balfyrd7sRpd6DRaUI1TwoOwYjLyRSd7mwZT5US8/edit# Over the course of 1 week, the browser process created 2MB+ speech-related objects that it did not destroy. Given that I never synthesize speech on my machine, I see two likely possibilities: 1) +[NSSpeechSynthesizer attributesForVoice:] is called many times, and each time leaks a relatively small number of objects. 2) +[NSSpeechSynthesizer attributesForVoice:] caches a huge amount of information in memory, and we should never have called it to begin with. e.g. We should add lazy initialization to TtsMessageFilter::OnInitializeVoiceList, or maybe that method itself should be lazily invoked.
,
Jul 18 2017
,
Aug 1 2017
I don't use TTS or VoiceOver, so there are 2 problems: 1) Why does this logic get triggered for my device? 2) Why does it leak?
,
Aug 1 2017
This seems to be related to this call: https://cs.chromium.org/chromium/src/chrome/browser/speech/tts_mac.mm?q=NSSpeechSynthesizer+attributesForVoice&dr=C&l=224 Which is an system library call: https://developer.apple.com/documentation/appkit/nsspeechsynthesizer/1448458-attributesforvoice I won't be surprised that just calling this code in loop will reveal the leak.
,
Aug 1 2017
When trying this, we need to be sure that the loop has autorelease pool in the body. Else, the leak is expected.
,
Aug 1 2017
Strangely enough, I cannot get TtsPlatformImplMac::GetVoices to ever trigger on my machine. Erik, could this be some extension that causes it to trigger?
,
Aug 1 2017
Theoretically possible, but not intentionally, if so. The only extensions I run are standard corp extensions, and AdBlock and TraceOnTap. I also don't use VoiceOVer, might that might cause a trigger.
,
Aug 1 2017
I managed to get a repro in combination of enabling/disabling siri and launching youtube.com
,
Aug 2 2017
Running the code in a loop does not exhibit linear increase of the the browser process memory. I will run under Instruments too.
,
Aug 2 2017
,
Aug 21 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by erikc...@chromium.org
, Jul 18 2017Components: Blink>Speech
Labels: Performance-Memory OS-Mac