Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(replay): Use unwrapped setTimeout to avoid e.g. angular change detection #11924

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented May 6, 2024

This PR makes sure we use the native, unwrapped setTimeout implementation of the browser. Some environments, e.g. Angular, monkey patch this for their change detection, leading to performance issues (possibly). We have already changed this in rrweb, but we also have some usage of this in replay itself.

This PR should work fine, however all test fail today because we heavily use jest.useFakeTimers(), which basically monkey patches fetch too. So with this change, we do not use the patched timers, leading to everything blowing up 🤯

Based on #11864
Depends on #11899

Copy link
Contributor

github-actions bot commented May 6, 2024

size-limit report 📦

Path Size
@sentry/browser 21.72 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) 32.86 KB (-0.04% 🔽)
@sentry/browser (incl. Tracing, Replay) 68.23 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.64 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.26 KB (-0.02% 🔽)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.27 KB (+0.01% 🔺)
@sentry/browser (incl. Feedback) 37.68 KB (+0.03% 🔺)
@sentry/browser (incl. sendFeedback) 26.29 KB (+0.02% 🔺)
@sentry/browser (incl. FeedbackAsync) 30.67 KB (+0.02% 🔺)
@sentry/react 24.42 KB (+0.03% 🔺)
@sentry/react (incl. Tracing) 35.86 KB (-0.03% 🔽)
@sentry/vue 25.66 KB (-0.02% 🔽)
@sentry/vue (incl. Tracing) 34.68 KB (-0.05% 🔽)
@sentry/svelte 21.86 KB (+0.01% 🔺)
CDN Bundle 24.25 KB (-0.04% 🔽)
CDN Bundle (incl. Tracing) 34.31 KB (-0.02% 🔽)
CDN Bundle (incl. Tracing, Replay) 68 KB (-0.02% 🔽)
CDN Bundle (incl. Tracing, Replay, Feedback) 72.96 KB (-0.02% 🔽)
CDN Bundle - uncompressed 71.31 KB (-0.03% 🔽)
CDN Bundle (incl. Tracing) - uncompressed 101.73 KB (-0.02% 🔽)
CDN Bundle (incl. Tracing, Replay) - uncompressed 211.35 KB (-0.01% 🔽)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 223.66 KB (-0.01% 🔽)
@sentry/nextjs (client) 35.12 KB (+0.09% 🔺)
@sentry/sveltekit (client) 33.47 KB (+0.04% 🔺)
@sentry/node 141.45 KB (0%)
@sentry/aws-serverless 128.08 KB (0%)

@billyvg billyvg marked this pull request as ready for review May 7, 2024 14:04
@billyvg billyvg requested a review from a team as a code owner May 7, 2024 14:04
@billyvg billyvg requested a review from mydea May 7, 2024 14:04
Base automatically changed from feat-use-vitest-replay to develop May 8, 2024 10:36
mydea and others added 8 commits May 8, 2024 07:09
This moves some code around in `browser-utils` so we can-reuse the logic for getting the unwrapped fetch implementation to also get the unwrapped `setTimeout` implementation. E.g. Angular wraps this for change detection, which can lead to performance degration.
This reverts commit 78221f5.
@billyvg billyvg force-pushed the fn/replay-unwrapped-setTimeout-billy branch from 0c5bfa2 to 6940018 Compare May 8, 2024 11:09
@billyvg
Copy link
Member Author

billyvg commented May 8, 2024

tracing/metrics/ tests are flaking a lot, not sure if related to this change specifically

@mydea mydea requested a review from Lms24 May 16, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants