marcoarment / BugshotKit

iOS in-app bug reporting for developers and testers, with annotated screenshots and the console log.
MIT License
1.36k stars 138 forks source link

100% CPU Usage #25

Open alexito4 opened 10 years ago

alexito4 commented 10 years ago

Hi! I recently fund that when I'm developing in the iOS Simulator my mac use one core at 100% and, consequently, the fans work and full speed and the temperature rises a lot. At first I was thinking that maybe is some bug with a new version of the simulator. But I tried to use instruments to search for some bug in my code and I found that BugshotKit is causing this. Specifically -[BugshotKit updateFromASL] method.

Instruments

I suppose that this method is the one that checks for logs. This happen every time I output a log in my code. But the main problem is that a single line of Log makes this method consume 100% of cpu time for 5 seconds or more.

Is this a normal behavior (because we are trying to read the logs) or is this a real issue?

Thanks! ;)

marcoarment commented 10 years ago

Is this under very heavy logging activity? Roughly how many messages are logged at this point in execution? Tens? Hundreds? Thousands? More?

There's no good efficient way to track new ASL messages on iOS. updateFromASL needs to request all entries from the log API (which I think is limited to the most recent 256) and match them against its internal copy to detect and add new ones.

For responsiveness in picking up new lines, it's triggered by a dispatch_source on stderr. But to avoid dominating the CPU under heavy logging, the consoleRefreshThrottler is meant to rate-limit it. Maybe that's not working right.

alexito4 commented 10 years ago

After some time in execution, yes, maybe there are a lot of logs (from core data debugging), but not thousands. But just after starting the app this also happens. It's very strange. For now I disabled BugshotKit while I'm developing.

Thanks for answering ;)