Skip to content

Conversation

@romtsn
Copy link
Member

@romtsn romtsn commented Dec 18, 2024

📜 Description

  • Switch touch events from LinkedList with a lock to ConcurrentLinkedDeque which suits this case better. Iterators of this deque are weakly consistent, which means it's possible another thread will add new touch events while we're iterating but this is fine for us, because we filter them out based on timestamp upon sending, so the newly-added touch events won't make it to the current segment, but to the next one.
  • Get rid of storing touch events to disk (for now), because it was overloading cpu a lot, and we only need them for the last segment in case of an ANR or Crash. iOS is currently not storing them either, so I think it's fine. But we should do it eventually, after we have proper disk serialization support (like serialize a single touch event, instead of the entire collection everytime)
  • Pre-allocate some arraylists for GestureRecorder to avoid growing them on the main thread
  • Get rid of one (out of 4) background threads in replay to avoid thread context switching. We reuse the same executor for masking screenshots that we use for creating segments/etc. My plan is to eventually have only 1 (or maybe 2) threads for the alll the replay stuff, but that's for followup PRs.

💡 Motivation and Context

Part of getsentry/sentry#74441
Fixes #3693 (partially, but not sure how to fix the first ANR there, so let's close it for now until we get actual reports about that)

💚 How did you test it?

Manually + automated

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@github-actions
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 662.57 ms 753.70 ms 91.13 ms
Size 1.70 MiB 2.36 MiB 671.39 KiB

Copy link
Contributor

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

looks good!

@romtsn romtsn merged commit 91bb628 into main Dec 20, 2024
33 checks passed
@romtsn romtsn deleted the rz/fix/session-replay-anr-ontouchevent branch December 20, 2024 17:24
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.

[SR] ANRs in Session Replay

3 participants