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

[SR] Introduce capture strategies and handle orientation change for buffer #3357

Merged

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Apr 15, 2024

#skip-changelog

📜 Description

  • Introduce different capture strategies (Buffer and Session) to simplify their handling and not rely on if-else check everywhere. ReplayIntegration is very lean now used for glueing everything together
    • BaseCaptureStrategy contains common pieces for both
  • Handle orientation change for buffer mode - we capture segments whenever orientation change happens and keep them in memory until an error happens. We also rotate already captured segments when necessary
  • Added one small thing for session mode - if a fatal crash happens, we try to capture the current segment to send as complete replay as possible

💡 Motivation and Context

Part of getsentry/sentry#63255

Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 441.64 ms 522.45 ms 80.81 ms
Size 1.70 MiB 2.32 MiB 630.58 KiB

Baseline results on branch: rz/feat/session-replay

Startup times

Revision Plain With Sentry Diff
4905abb 394.22 ms 532.53 ms 138.31 ms
9576d82 413.17 ms 484.73 ms 71.56 ms
54ce31d 356.89 ms 426.10 ms 69.21 ms
8e7260f 367.84 ms 445.06 ms 77.22 ms

App size

Revision Plain With Sentry Diff
4905abb 1.70 MiB 2.31 MiB 627.54 KiB
9576d82 1.70 MiB 2.31 MiB 627.54 KiB
54ce31d 1.70 MiB 2.31 MiB 627.54 KiB
8e7260f 1.70 MiB 2.31 MiB 627.54 KiB

}
}

protected sealed class ReplaySegment {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

)
if (segment is ReplaySegment.Created) {
segment.capture(hub)
currentSegment.getAndIncrement()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case segment creation fails, would you need to increment currentSegment.getAndIncrement() as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I think we'd want to try and capture the next time with the same segmentId to avoid gaps. That's a good point for future though, as we could create an rrweb_event indicating the failure and reflect the gap somehow on the playback. I'll add this to ideas list 👍

@romtsn romtsn merged commit 12c0eb7 into rz/feat/session-replay Apr 25, 2024
22 checks passed
@romtsn romtsn deleted the rz/feat/session-replay-capture-strategies branch April 25, 2024 10:04
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.

2 participants