New issue
Advanced search Search tips

Issue 745083 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

+[NSSpeechSynthesizer attributesForVoice:] consumes 2MB+ of memory on macOS.

Project Member Reported by erikc...@chromium.org, Jul 17 2017

Issue description

I'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.

 
Screen Shot 2017-07-17 at 4.55.15 PM.png
213 KB View Download
Screen Shot 2017-07-17 at 4.55.36 PM.png
173 KB View Download
Screen Shot 2017-07-17 at 4.55.55 PM.png
172 KB View Download
Cc: borisv@chromium.org
Components: Blink>Speech
Labels: Performance-Memory OS-Mac

Comment 2 by borisv@chromium.org, Jul 18 2017

Owner: borisv@chromium.org
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?
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.
When trying this, we need to be sure that the loop has autorelease pool in the body. Else, the leak is expected.
Strangely enough, I cannot get TtsPlatformImplMac::GetVoices to ever trigger on my machine. Erik, could this be some extension that causes it to trigger?
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.
I managed to get a repro in combination of enabling/disabling siri and launching youtube.com
Running the code in a loop does not exhibit linear increase of the the browser process memory. I will run under Instruments too.
Cc: etienneb@chromium.org
Status: Assigned (was: Untriaged)

Sign in to add a comment