-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): Avoid recording long animation frame spans starting bef…
…ore their parent span (#14186) - Check for start time of parent navigation span and don't start long animation frame span if its start timestamp is earlier than the navigation start time stamp - Refactor span starting logic to use common helper function to compensate the bundle size increase - Add regression test that failed previously - Improve regression test from #14183 to avoid flakes and improve the in-test navigation
- Loading branch information
Showing
8 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...s/suites/tracing/browserTracingIntegration/long-animation-frame-before-navigation/init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [ | ||
Sentry.browserTracingIntegration({ | ||
idleTimeout: 9000, | ||
enableLongTask: false, | ||
enableLongAnimationFrame: true, | ||
instrumentPageLoad: false, | ||
enableInp: false, | ||
}), | ||
], | ||
tracesSampleRate: 1, | ||
}); |
18 changes: 18 additions & 0 deletions
18
...uites/tracing/browserTracingIntegration/long-animation-frame-before-navigation/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function getElapsed(startTime) { | ||
const time = Date.now(); | ||
return time - startTime; | ||
} | ||
|
||
function handleClick() { | ||
const startTime = Date.now(); | ||
while (getElapsed(startTime) < 105) { | ||
// | ||
} | ||
window.history.pushState({}, '', `#myHeading`); | ||
} | ||
|
||
const button = document.getElementById('clickme'); | ||
|
||
console.log('button', button); | ||
|
||
button.addEventListener('click', handleClick); |
13 changes: 13 additions & 0 deletions
13
...es/tracing/browserTracingIntegration/long-animation-frame-before-navigation/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button id="clickme"> | ||
click me to start the long animation! | ||
</button> | ||
|
||
<h1 id="myHeading">My Heading</h1> | ||
</body> | ||
</html> |
31 changes: 31 additions & 0 deletions
31
...s/suites/tracing/browserTracingIntegration/long-animation-frame-before-navigation/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
sentryTest( | ||
"doesn't capture long animation frame that starts before a navigation.", | ||
async ({ browserName, getLocalTestPath, page }) => { | ||
// Long animation frames only work on chrome | ||
if (shouldSkipTracingTest() || browserName !== 'chromium') { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
|
||
const navigationTransactionEventPromise = getFirstSentryEnvelopeRequest<Event>(page); | ||
|
||
await page.locator('#clickme').click(); | ||
|
||
const navigationTransactionEvent = await navigationTransactionEventPromise; | ||
|
||
expect(navigationTransactionEvent.contexts?.trace?.op).toBe('navigation'); | ||
|
||
const loafSpans = navigationTransactionEvent.spans?.filter(s => s.op?.startsWith('ui.long-animation-frame')); | ||
|
||
expect(loafSpans?.length).toEqual(0); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,4 @@ Sentry.init({ | |
}), | ||
], | ||
tracesSampleRate: 1, | ||
debug: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters