Skip to content

⚗️ Replace canvas recording knobs with quality presets, dedupe downscaling for hashing, and switch to WebP - #5034

Merged
BeltranBulbarellaDD merged 9 commits into
mainfrom
beltran.bulbarella/dedupe-canvas-downscale
Sep 15, 2026
Merged

BeltranBulbarellaDD merged 9 commits into
mainfrom
beltran.bulbarella/dedupe-canvas-downscale

Conversation

@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor

Motivation

The experimental canvas recording feature (sessionReplayCanvasRecording) exposed raw numeric knobs (maxFramesPerSecond, hashingMaxDimension, maxImageDimension) that are hard for customers to reason about, and frame rate/quality defaults were more conservative than what other platforms offer for canvas replay. This is a step towards a customer-friendly, production-ready config surface, while it's still gated behind an experimental flag.

Changes

  • Replaced the raw sessionReplayCanvasRecording knobs with a single quality option (low / medium / high), each preset internally mapping to a full bundle of capture rate, hashing/image dimensions, and encode quality.
  • Raised the effective max capture rate ceiling (up to 8 fps on high), bringing us more in line with what other platforms offer for canvas recording.
  • Switched captured canvas frame encoding from PNG to WebP, which produces significantly smaller payloads for the same visual fidelity while still supporting the alpha channel (unlike JPEG).
  • Extracted a shared createDownscaledCanvas helper used by both the snapshot and hashing paths, removing duplicated canvas-downscaling logic.

This only affects the @hidden, experimental sessionReplayCanvasRecording option, so no deprecation/migration path is needed.

Test instructions

  • yarn typecheck
  • yarn test:unit --spec packages/browser-rum-core/src/domain/configuration/configuration.spec.ts
  • yarn test:unit --spec packages/browser-rum/src/domain/record/canvas/canvasSnapshot.spec.ts
  • yarn test:unit --spec packages/browser-rum/src/domain/record/trackers/trackCanvasCapture.spec.ts
  • yarn test:unit --spec packages/browser-rum/src/domain/record/trackers/trackCanvasContent.spec.ts
  • yarn test:unit --spec packages/browser-rum/src/domain/record/record.spec.ts

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

BeltranBulbarellaDD and others added 2 commits September 10, 2026 17:33
canvasSnapshot.ts and canvasHash.ts each reimplemented the same
scale-and-drawImage logic to resize a canvas to a max dimension.
Extract createDownscaledCanvas as a shared helper, and skip the
redundant downscale in computeImageHash when the frozen snapshot
already fits within maxHashDimension.
…frames as WebP

Replace the raw maxFramesPerSecond/hashingMaxDimension/maxImageDimension
options with a single `quality` preset (low/medium/high), raising the
default and max capture rate ceiling to better match other platforms'
canvas recording experience. Also switch captured frame encoding from
PNG to WebP for smaller payloads while keeping alpha channel support.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@BeltranBulbarellaDD
BeltranBulbarellaDD requested review from a team as code owners September 10, 2026 16:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T08:44:11.359807Z 7832a4b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 83.33%
• Overall Coverage: 77.04% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7832a4b | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 184.83 KiB 185.11 KiB +285 B +0.15% ✅
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00% ✅
Rum Recorder 28.20 KiB 28.17 KiB -25 B -0.09% ✅
Logs 58.70 KiB 58.70 KiB 0 B 0.00% ✅
Rum Salesforce N/A 143.15 KiB N/A N/A N/A
Rum Slim 142.84 KiB 143.14 KiB +312 B +0.21% ✅
Worker 22.96 KiB 22.96 KiB 0 B 0.00% ✅
Rum Shopify N/A 212.78 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.74 KiB N/A N/A N/A

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title Replace canvas recording knobs with quality presets and WebP encoding ⚗️ Replace canvas recording knobs with quality presets, dedupe downscaling for hashing, and switch to WebP Sep 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7f7f4b61d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/browser-rum-core/src/domain/configuration/configuration.ts
Comment thread packages/browser-rum/src/domain/record/canvas/canvasSnapshot.spec.ts Outdated
Comment thread packages/browser-rum/src/domain/record/canvas/canvasSnapshot.spec.ts Outdated
…as tests

Re-export CanvasRecordingQuality from the RUM and RUM Slim public entry
points so customers can reference the preset constants, matching the
DefaultPrivacyLevel pattern. Also fix canvas image unit tests that
assumed WebP encoding unconditionally: some BrowserStack targets
(older Firefox/Safari) fall back to PNG per spec when WebP isn't
supported, and lossy WebP can shift pixel values by a few units even
at high quality, so assertions now tolerate both cases.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6ef40ea12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/browser-rum-core/src/domain/configuration/configuration.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 847bace38d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sethfowler-datadog sethfowler-datadog 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.

LGTM; all nice improvements!

Comment on lines +628 to +632
const sessionReplayCanvasRecording =
isExperimentalFeatureEnabled(ExperimentalFeature.SESSION_REPLAY_RECORD_CANVAS) &&
config.sessionReplayCanvasRecording?.enable
? { enable: true as const, ...CANVAS_RECORDING_QUALITY_PRESETS[config.sessionReplayCanvasRecording.quality] }
: undefined

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.

Nit: maybe worth creating a helper function at this point. It may also make sense to not enable canvas recording if config.sessionReplayCanvasRecording.quality does not appear in CANVAS_RECORDING_QUALITY_PRESETS, just so that downstream code doesn't have to worry about receiving an enable: true configuration that doesn't have any of the settings configured.

@BeltranBulbarellaDD
BeltranBulbarellaDD merged commit d6123da into main Sep 15, 2026
31 checks passed
@BeltranBulbarellaDD
BeltranBulbarellaDD deleted the beltran.bulbarella/dedupe-canvas-downscale branch September 15, 2026 13:37
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants