-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 requestIdleCallback
for events
#7191
Conversation
size-limit report 📦
|
Replay SDK metrics 🚀
develop |
Revision | LCP | CLS | CPU | JS heap avg | JS heap max | netTx | netRx | netCount | netTime |
---|---|---|---|---|---|---|---|---|---|
1c9ed4f | +50.07 ms | -0.00 ms | +6.39 pp | +928.84 kB | +1.05 MB | +2.2 kB | +41 B | +1 | +70.97 ms |
1921888 | +55.79 ms | +0.00 ms | +5.50 pp | +926.71 kB | +1.06 MB | +2.23 kB | +41 B | +1 | +79.78 ms |
e9eec27 | +61.38 ms | -0.00 ms | +6.04 pp | +927.84 kB | +1.05 MB | +2.21 kB | +41 B | +1 | +88.58 ms |
d604022 | +58.83 ms | -0.00 ms | +7.65 pp | +930.16 kB | +1.05 MB | +2.21 kB | +41 B | +1 | +109.63 ms |
a961e57 | +54.75 ms | -0.00 ms | +6.50 pp | +929.18 kB | +1.07 MB | +2.21 kB | +41 B | +1 | +92.73 ms |
f7c0a2f | +46.14 ms | +0.00 ms | +6.37 pp | +921.47 kB | +1.06 MB | +2.23 kB | +41 B | +1 | +207.30 ms |
cb19818 | +57.16 ms | +0.00 ms | +11.95 pp | +1.07 MB | +2.21 MB | +2.52 kB | +41 B | +1 | +111.50 ms |
ee301c3 | +71.07 ms | -0.00 ms | +12.64 pp | +1.07 MB | +2.22 MB | +2.55 kB | +41 B | +1 | +94.67 ms |
93c4759 | +61.10 ms | -0.00 ms | +12.72 pp | +1.08 MB | +2.19 MB | +2.57 kB | +41 B | +1 | +116.75 ms |
Last updated: Wed, 15 Feb 2023 11:25:05 GMT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hold off on this change for now unless we can show some measureable improvements
Yes, definitely! |
Closing this for now, as we're going to explore a different approach - see getsentry/rrweb#58 |
This PR updates the event handling of replay to use
window.requestIdleCallback
, if available.This API is supported everywhere except for Safari, and should schedule a callback to be run when the browser has "resources" for it.
Hopefully, this should improve performance in scenarios where a lot of events are emitted.
I defined a max. timeout of
50ms
, meaning that after max. 50ms each callback will be executed anyhow. This could be tweaked, but feels like a reasonably defensive value here. If the API is not available, we just run the callbacks immediately (like now), so it should degrade gracefully.Note that there would also be an approach to only have a single callback that keeps an internal queue, but that would require more work to ensure that events cannot be postponed for too long, so IMHO this is the easier solution.
I tried this in my super simple test app, where it works as expected. it would be nice though to test this in a more complex app...
Note: I also refactored the
addUpdate
method to split this into dedicated methods, as this was a bit mixed up right now. Now, we have a dedicated (private) method for the event emitting, and one for adding a "generic" event from other handlers etc.See https://w3c.github.io/requestidlecallback/ for some more info.
ref #6946
ref #7085