Skip to content

Commit

Permalink
fix offset calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Mar 6, 2025
1 parent a745650 commit 8d29eeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ 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
16 changes: 6 additions & 10 deletions static/app/utils/profiling/profile/importProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export function eventedProfileToSampledProfile(
samples.push({
stack_id: stackId,
thread_id: String(profile.threadID),
timestamp: current.at * 1e-9,
timestamp: profile.startValue + current.at * 1e-9,
});

stacks[stackId] = stack.slice();
Expand All @@ -306,7 +306,8 @@ export function eventedProfileToSampledProfile(
samples.push({
stack_id: stackId,
thread_id: String(profile.threadID),
timestamp: profile.events[profile.events.length - 1]!.at * 1e-9,
timestamp:
profile.startValue + profile.events[profile.events.length - 1]!.at * 1e-9,
});
stacks[stackId] = stack.slice();
stackId++;
Expand Down Expand Up @@ -363,14 +364,12 @@ export function importAndroidContinuousProfileChunk(
samplesByThread[sample.thread_id]!.push(sample);
}

for (const key in samplesByThread) {
samplesByThread[key]!.sort((a, b) => a.timestamp - b.timestamp);
}

const profiles: ContinuousProfile[] = [];
let activeProfileIndex = input.activeProfileIndex ?? 0;

for (const key in samplesByThread) {
samplesByThread[key]!.sort((a, b) => a.timestamp - b.timestamp);

const profile: Profiling.ContinuousProfile = {
...convertedProfile,
frames,
Expand Down Expand Up @@ -442,14 +441,11 @@ export function importSentryContinuousProfileChunk(
samplesByThread[sample.thread_id]!.push(sample);
}

for (const key in samplesByThread) {
samplesByThread[key]!.sort((a, b) => a.timestamp - b.timestamp);
}

const profiles: ContinuousProfile[] = [];
let activeProfileIndex = 0;

for (const key in samplesByThread) {
samplesByThread[key]!.sort((a, b) => a.timestamp - b.timestamp);
const profile: Profiling.ContinuousProfile = {
...input,
...input.profile,
Expand Down

0 comments on commit 8d29eeb

Please sign in to comment.