diff --git a/import/chrome.ts b/import/chrome.ts index e280fff..be05af3 100644 --- a/import/chrome.ts +++ b/import/chrome.ts @@ -45,12 +45,17 @@ interface CPUProfile { } export function importFromChromeTimeline(events: TimelineEvent[]) { - const profileEvent = events[events.length - 1] - const chromeProfile = profileEvent.args.data.cpuProfile as CPUProfile - return importFromChromeCPUProfile(chromeProfile) + // It seems like sometimes Chrome timeline files contain multiple CpuProfiles? + // For now, choose the first one in the list. + for (let event of events) { + if (event.name == "CpuProfile") { + const chromeProfile = event.args.data.cpuProfile as CPUProfile + return importFromChromeCPUProfile(chromeProfile) + } + } + throw new Error("Could not find CPU profile in Timeline") } - const callFrameToFrameInfo = new Map() function frameInfoForCallFrame(callFrame: CPUProfileCallFrame) { return getOrInsert(callFrameToFrameInfo, callFrame, (callFrame) => {