Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

WebView bridge always advertises the "records" capability, forcing Browser SDK recording when Session Replay is not enabled

Closed
#3,936 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #3937 by @notcool11 — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

Start in features/dd-sdk-android-webview/src/main/kotlin/com/datadog/android/webview/internal/DatadogEventBridge.kt at getCapabilities(), then inspect how the Session Replay feature is registered and identified. Add unit tests covering registered and unregistered Session Replay states, including registration after WebViewTracking.enable(). Done means the bridge advertises records only when Session Replay is registered.

Written by the indexing model from the issue text.

Description

Describe the bug

DatadogEventBridge.getCapabilities() always returns ["records"], whether or not Session Replay is enabled in the host app:

https://github.com/DataDog/dd-sdk-android/blob/3.11.0/features/dd-sdk-android-webview/src/main/kotlin/com/datadog/android/webview/internal/DatadogEventBridge.kt#L123-L125

internal val capabilities = JsonArray().apply {
    add("records")
}

The Browser SDK reads this value to decide whether to record. computeSessionReplayState() returns SAMPLED whenever the bridge supports RECORDS, ignoring sample rates, and makeRecorderApi() only turns into a no-op when that capability is missing. So in every tracked WebView of an app that does not use Session Replay, the Browser SDK still starts the recorder. It serializes the DOM, watches mutations, and sends record events over the bridge. The native side then drops them because there is no WebViewReplayFeature (NoOpDataWriter). The work costs CPU and bridge traffic in the WebView and produces nothing.

The Android SDK already knows about this case in another place. WebViewRumEventMapper strips _dd.replay_stats and session.has_replay when native SR is off (RUM-4084). The capability advertised to the Browser SDK was never made conditional in the same way.

The iOS SDK advertises the capability only when Session Replay is registered:

https://github.com/DataDog/dd-sdk-ios/blob/develop/DatadogWebViewTracking/Sources/WebViewTracking.swift#L185

It checks core.feature(named: "session-replay", type: SessionReplayConfiguration.self) each time it injects the bridge script, and leaves the capabilities empty when that returns nil.

The hardcoded value was added in e22c43e44 (#1871, "RUM-3281 Implement webview bridge getCapabilities") and is unchanged on develop.

Reproduction steps
  1. In an app with RUM enabled but without dd-sdk-android-session-replay, call WebViewTracking.enable(webView, allowedHosts) and load a page that initialises the Browser SDK (v5+).
  2. Inspect the WebView with chrome://inspect and run DatadogEventBridge.getCapabilities(). It returns ["records"].
  3. Watch DatadogEventBridge.send(...) traffic. Alongside the RUM events, the page emits {"eventType":"record",...} messages, and the native SDK discards them.

I'll follow up in a comment with measured before/after numbers from a real app.

Expected behavior

getCapabilities() returns ["records"] only when the Session Replay feature is registered, and [] otherwise, the same as iOS. The Browser SDK then keeps its recorder as a no-op when the host app has no Session Replay.

Affected SDK versions

3.11.0 through current develop (hardcoded since the capability was introduced)

Latest working SDK version

None known. The capability has been unconditional since it was added.

Did you confirm if the latest SDK version fixes the bug?

No. Confirmed by reading develop, where the code is unchanged.

Kotlin / Java version

Kotlin 2.2.0 / Java 21

Gradle / AGP version

Gradle 8.13 / AGP 8.11.0

Other dependencies versions

Browser SDK 7.8.0 on the embedded page

Device Information

Not device-specific; the value is hardcoded. Testing on a Pixel 6 emulator (API 36).

Other relevant information

I'd like to contribute the fix: check Feature.SESSION_REPLAY_FEATURE_NAME on every getCapabilities() call, because the bridge lives across page loads and SR may be registered after WebViewTracking.enable(). I'll open a PR from a fork that references this issue, with unit tests and before/after measurements.

Dominant language
Kotlin
Stars
227
Forks
88
Avg merge
1d 14h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DataDog/dd-sdk-android

All issues in DataDog/dd-sdk-android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.