Skip to content

Commit

Permalink
fix rendering of android profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Mar 6, 2025
1 parent 8d29eeb commit 735f66b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ function getProfileOffset(
return Rect.Empty();
}

// @todo(jonas): uncomment this when we figure out where to anchor android continuous profiles
if (profile.startedAt - startedAtMs < 0) {
return Rect.Empty();
}

return new Rect(profile.startedAt - startedAtMs, 0, 0, 0);
}

Expand Down
21 changes: 16 additions & 5 deletions static/app/utils/profiling/profile/importProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export function importSchema(
}

export function eventedProfileToSampledProfile(
profileTimestamp: number,
input: ReadonlyArray<Readonly<Profiling.EventedProfile>>
): Pick<
Readonly<Profiling.SentryContinousProfileChunk>['profile'],
Expand Down Expand Up @@ -293,10 +294,10 @@ export function eventedProfileToSampledProfile(
samples.push({
stack_id: stackId,
thread_id: String(profile.threadID),
timestamp: profile.startValue + current.at * 1e-9,
timestamp: profileTimestamp + current.at * 1e-9,
});

stacks[stackId] = stack.slice();
stacks[stackId] = stack.slice().reverse();
stackId++;
currentTimestamp = current.at;
}
Expand All @@ -307,9 +308,9 @@ export function eventedProfileToSampledProfile(
stack_id: stackId,
thread_id: String(profile.threadID),
timestamp:
profile.startValue + profile.events[profile.events.length - 1]!.at * 1e-9,
profileTimestamp + profile.events[profile.events.length - 1]!.at * 1e-9,
});
stacks[stackId] = stack.slice();
stacks[stackId] = stack.slice().reverse();
stackId++;
}
}
Expand Down Expand Up @@ -352,7 +353,17 @@ export function importAndroidContinuousProfileChunk(
Profiling.SentryContinousProfileChunk['profile']['samples']
> = {};

const convertedProfile = eventedProfileToSampledProfile(input.profiles);
if (!input.metadata.timestamp) {
throw new TypeError(
'No timestamp found in metadata, typestamp is required to render continuous profiles'
);
}
const profileTimestampInSeconds = new Date(input.metadata.timestamp).getTime() * 1e-3;

const convertedProfile = eventedProfileToSampledProfile(
profileTimestampInSeconds,
input.profiles
);

// @todo(jonas): implement measurements
const minTimestamp = minTimestampInChunk({...convertedProfile, frames}, {});
Expand Down

0 comments on commit 735f66b

Please sign in to comment.