Tracking down infinite loop with memory leak in my own addon

I’m getting some reports from a very few users (below 0.01%) that suggests there is an infinite loop in my addon consuming all memory (many GB).

Since my codebase is huge (5 years of full-time code), there is no way to check everything.

Is there some way to track down the infinite loop if I can’t reproduce it but my user can?

I was thinking:

  • use the Firefox profiler? Will that point out what js method is being called?
  • use some logger? But how to log everything and how to store the data?

Yes, If some of the few users are able to collect a profile, that is likely going to provide some useful details about what may be going on (at least if the user is able to collect profile data while the problem is happening, e.g. while the memory usage is growing).

Another way to try to get some more useful context would be to ask those users to try to collect a memory usage report from about:memory (that may provide some hints based on what kind of data is actually using the bigger amount of memory, and also if the memory usage is growing in the child extension process or in the main Firefox process).

If based on the additional data you may be able to collect from your users it looks like there may be an issue on the Firefox side that your extension may be revealing, feel free to ping me in this thread or on github (e.g. in the issue filed in the extension repository if it is hosted on github, my github handle is https://github.com/rpl) so that I can try to help further (e.g. to better assess what is going on and then track the issue also on bugzilla if there is a issue on the Firefox side to investigate).

2 Likes

Thanks! Good idea with the about:memory!
I’m really getting desperate with these issues. Infinite loop is really the worst.

Anyway, the last report I’ve received was actually caused by another addon that somehow “collide” with my addon (Group Speed Dial). So even though disabling my addon helped solving the problem, the real issue was actually in a different addon - the “Ant Video Downloader” which already has a bunch of recent bad reviews complaining about a memory leak.

Actually, now that I’m thinking about it, the “collision area” between two addons is not that huge. If disabling my addon helped, then it must be some event listener in MY code that reacts on other addon action… hmmm… onMessageExternal… :open_mouth:!

I don’t think this is a Firefox issue since two older reports came from Chromium users.
But I have a feeling there is much more cases then reports. Because once the memory runs out, the ‘webextension’ process crashes but the browser will still work, right?
And I’ve received much more reports where the background script doesn’t respond anymore - my addon then shows only blank page with error - these cases could be caused by the same issue.

If you have more tip-and-tricks, please share :slight_smile:.