Skip to content

Commit c21ecd4

Browse files
fix: Android SR, remove visible scrollbars (#371)
## Summary Match current iOS padding approach to remove scrollbars ## How did you test this change? <img width="341" height="451" alt="image" src="https://github.com/user-attachments/assets/ea004914-3398-488e-866b-fcd1b50b4e08" /> ## Are there any deployment considerations? Probably there is more stable way, but this one works <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small, localized change to session replay event generation; main risk is slight coordinate/layout mismatch if consumers assume unpadded dimensions. > > **Overview** > Adds a fixed `RRWEB_DOCUMENT_PADDING` in `SessionReplayEventGenerator` and applies it to RRWeb meta sizing and touch coordinates. > > `META` events now report `width`/`height` with extra padding, and interaction events (`ACTION_DOWN`/`MOVE`/`UP`) offset `x`/`y` by the same amount so replays align with the padded document and avoid visible scrollbars. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 366da92. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 7a17d03 commit c21ecd4

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/exporter/SessionReplayEventGenerator.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import kotlinx.serialization.json.put
2222
class SessionReplayEventGenerator(
2323
private val canvasDrawEntourage: Int
2424
) {
25+
companion object {
26+
private const val RRWEB_DOCUMENT_PADDING = 11
27+
}
28+
2529
/**
2630
* Sequence ID for the events being generated.
2731
* Each event in a session needs a unique, monotonically increasing "sid".
@@ -86,9 +90,9 @@ class SessionReplayEventGenerator(
8690
sid = nextSid(),
8791
data = EventDataUnion.StandardEventData(
8892
EventData(
89-
width = captureEvent.origWidth,
90-
height = captureEvent.origHeight,
91-
)
93+
width = captureEvent.origWidth + RRWEB_DOCUMENT_PADDING * 2,
94+
height = captureEvent.origHeight + RRWEB_DOCUMENT_PADDING * 2,
95+
)
9296
),
9397
)
9498
eventBatch.add(metaEvent)
@@ -182,7 +186,7 @@ class SessionReplayEventGenerator(
182186
timestamp = firstPosition.timestamp,
183187
sid = nextSid(),
184188
data = EventDataUnion.CustomEventDataWrapper(
185-
Json.parseToJsonElement("""{"source":2,"texts": [],"type":7,"id":6,"x":${firstPosition.x}, "y":${firstPosition.y}}""")
189+
Json.parseToJsonElement("""{"source":2,"texts": [],"type":7,"id":6,"x":${firstPosition.x + RRWEB_DOCUMENT_PADDING}, "y":${firstPosition.y + RRWEB_DOCUMENT_PADDING}}""")
186190
)
187191
)
188192
)
@@ -206,7 +210,7 @@ class SessionReplayEventGenerator(
206210
timestamp = lastPosition.timestamp,
207211
sid = nextSid(),
208212
data = EventDataUnion.CustomEventDataWrapper(
209-
Json.parseToJsonElement("""{"source":2,"texts": [],"type":9,"id":6,"x":${lastPosition.x}, "y":${lastPosition.y}}""")
213+
Json.parseToJsonElement("""{"source":2,"texts": [],"type":9,"id":6,"x":${lastPosition.x + RRWEB_DOCUMENT_PADDING}, "y":${lastPosition.y + RRWEB_DOCUMENT_PADDING}}""")
210214
)
211215
)
212216
)
@@ -221,7 +225,7 @@ class SessionReplayEventGenerator(
221225
timestamp = position.timestamp,
222226
sid = nextSid(),
223227
data = EventDataUnion.CustomEventDataWrapper(
224-
Json.parseToJsonElement("""{"positions": [{"id":6,"timeOffset":0,"x":${position.x},"y":${position.y}}], "source": 6}""")
228+
Json.parseToJsonElement("""{"positions": [{"id":6,"timeOffset":0,"x":${position.x + RRWEB_DOCUMENT_PADDING},"y":${position.y + RRWEB_DOCUMENT_PADDING}}], "source": 6}""")
225229
)
226230
)
227231
)

0 commit comments

Comments
 (0)