Skip to content

Conversation

@mbruin-NR
Copy link
Contributor

@mbruin-NR mbruin-NR commented Sep 8, 2025

The session replay persistence logic had two issues:

  1. Duplicate Touch Events: Touch events were being persisted multiple times to the filesystem.
  2. Excessive Meta Events: A meta event was being added for every single frame, even when the screen size hadn't changed.

Solution

1. Prevent Duplicate Touch Persistence

Added a tracking mechanism to ensure touch events are only persisted once:

  • Added isPersisted boolean flag to the TouchEvent class
  • Created a new getUnpersistedTouches() method that:
    • Filters touch events to only include unpersisted ones
    • Processes only those unpersisted touches
    • Marks them as persisted after processing

This ensures that each touch event is written to disk exactly once, eliminating duplicate data in the persisted session replay files.

2. Optimize Meta Event Generation

Meta events now only generate when necessary:

  • Track the last frame size using sessionReplayFrameProcessor.lastFullFrame?.size
  • Only add a meta event when:
    • The frame size has changed (e.g., device rotation)
  • Use the lastTimestamp for the meta event timestamp instead of firstTimestamp to maintain correct temporal ordering

@mbruin-NR mbruin-NR marked this pull request as ready for review November 13, 2025 18:34
@mbruin-NR mbruin-NR changed the title Fix to persist the touch events only once and only add meta events when needed. NR-488162 Fix to persist the touch events only once and only add meta events when needed. Nov 13, 2025
@mbruin-NR mbruin-NR merged commit cb267bc into develop Nov 13, 2025
13 checks passed
@mbruin-NR mbruin-NR deleted the msr_crash_duplicate_touches branch November 13, 2025 21: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.

3 participants