bamlab / flashlight

📱⚡️ Lighthouse for Mobile - audits your app and gives a performance score to your Android apps (native, React Native, Flutter..). Measure performance on CLI, E2E tests, CI...

Home Page:https://docs.flashlight.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Could not parse ATrace line "CPU:3 [LOST 4262 EVENTS]"

kirillzyusko opened this issue · comments

I'm getting error Error: Could not parse ATrace line "CPU:3 [LOST 4262 EVENTS]" in

interval: parseLine(lines[lines.length - 1]).timestamp - parseLine(lines[0]).timestamp,

And parent call happens from:

const { frameTimes, interval: atraceInterval } = frameTimeParser.getFrameTimes(atrace, pid);

Currently I fixed it with next construction:

  let output;
  try {
    output = frameTimeParser.getFrameTimes(atrace, pid);
  } catch (e) {
    console.error(e);
  }
  
  if (!output) {
    return;
  }
  
  const { frameTimes, interval: atraceInterval } = output;

In my opinion it's better to ignore one frame rather than crash the profiler.

The exception happens when I just launched emulator and run a lot of tests sequentially, the test execution is several seconds, then I do a short break (maybe 100ms) and repeat a test.

This is a full stack trace, but don't look at number of lines - I applied a patch, so some of line numbers are not correct:

Error: Could not parse ATrace line "CPU:2 [LOST 8693 EVENTS]"
    at parseLine (/Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/atrace/pollFpsUsage.ts:17:13)
    at FrameTimeParser.getFrameTimes (/Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/atrace/pollFpsUsage.ts:92:73)
    at /Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/platforms/UnixProfiler.ts:143:10
    at /Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/platforms/UnixProfiler.ts:202:9
    at /Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/shell.ts:110:7
    at Array.forEach (<anonymous>)
    at Socket.<anonymous> (/Users/kirylziusko/IdeaProjects/project/node_modules/@perf-profiler/android/src/commands/shell.ts:109:29)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)

Hi @kirillzyusko, apologies for the delay! We're usually faster than this

In my opinion it's better to ignore one frame rather than crash the profiler.

Yep, I agree, that makes a lot of sense!
Do you want to submit a PR to add your patch? I can pull them along with your other change in the next releases.

@Almouro Yeah, sure. I'll submit a PR today 🙌

@Almouro opened it here #295