Skip to content

fix(replay): Measure gesture batch durations on a monotonic clock (JAVA-830) - #6538

Merged
runningcode merged 2 commits into
mainfrom
no/java-830-replay-gesture-stopwatch
Nov 11, 2026
Merged

runningcode merged 2 commits into
mainfrom
no/java-830-replay-gesture-stopwatch

Conversation

@runningcode

@runningcode runningcode commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

This is part of the work to get rid of our uses of wall clocks where we should in fact be using monotonic clocks. Gesture tracking is a definite use case where we should be using monotonic clocks.

We batch gestures every 500ms.

Here's a little table of the two things we're changing in this PR created by my clanker. Note now in the chart below is dateProvider.currentTimeMillis. moveBatch for reference is a io.sentry.time.Stopwatch.

Site Before After
Batch timer now - touchMoveBaseline > 500 moveBatch.elapsed(MILLISECONDS) > 500
Position timeOffset now - touchMoveBaseline moveBatch.elapsed(MILLISECONDS)

What this PR deliberately does not change

The event timestamps (timestamp = now on the move event, and the touch start, end and cancel timestamps) are instants and stay on the wall clock. They move to an AnchoredClock in v9 (JAVA-829).

💡 Motivation and Context

Wall clocks are bad since they can move forward and backward and are not the correct tool for batching gestures.

💚 How did you test it?

Existing tests pass and new tests added:

  • wall clock stepping backwards during a swipe does not hold back the batch
  • wall clock stepping forwards during a swipe does not send the batch early

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Move the gesture event timestamps onto an AnchoredClock in v9 (JAVA-829).

🤖 Generated with Claude Code

Touch moves are batched and sent as one RRWebInteractionMoveEvent every 500ms. Both the batch
timer and each position's timeOffset subtracted wall-clock readings, so a clock step corrupted
them: a backward step held the batch back until the clock caught up, and dropped it if the finger
lifted first; a forward step sent it at once with offsets stretched by the step.

Both now come from one Stopwatch on the converter's MonotonicTicker, started with the first
batched position. Without a clock step the output is unchanged. The event timestamps stay on the
wall clock; they move to an AnchoredClock in v9.

Fixes JAVA-830
Fixes #6523

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

JAVA-830

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Nov 10, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode marked this pull request as ready for review November 10, 2026 12:58
@runningcode
runningcode requested review from a team and adinauer as code owners November 10, 2026 12:58
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 10, 2026 12:58
@runningcode runningcode added the sanity-check PR needs a lightweight review for obvious issues label Nov 10, 2026

@romtsn romtsn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice 🚀

@runningcode
runningcode merged commit 42fb799 into main Nov 11, 2026
61 of 63 checks passed
@runningcode
runningcode deleted the no/java-830-replay-gesture-stopwatch branch November 11, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session Replay gesture batching measures durations with the wall clock

2 participants