Repository navigation
⚗️ Replace canvas recording knobs with quality presets, dedupe downscaling for hashing, and switch to WebP - #5034
Conversation
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>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7832a4b | Docs | View more details | Give us feedback! |
Bundles Sizes Evolution
|
There was a problem hiding this comment.
💡 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".
…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>
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
💡 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
left a comment
There was a problem hiding this comment.
LGTM; all nice improvements!
| const sessionReplayCanvasRecording = | ||
| isExperimentalFeatureEnabled(ExperimentalFeature.SESSION_REPLAY_RECORD_CANVAS) && | ||
| config.sessionReplayCanvasRecording?.enable | ||
| ? { enable: true as const, ...CANVAS_RECORDING_QUALITY_PRESETS[config.sessionReplayCanvasRecording.quality] } | ||
| : undefined |
There was a problem hiding this comment.
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.
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
sessionReplayCanvasRecordingknobs with a singlequalityoption (low/medium/high), each preset internally mapping to a full bundle of capture rate, hashing/image dimensions, and encode quality.high), bringing us more in line with what other platforms offer for canvas recording.createDownscaledCanvashelper used by both the snapshot and hashing paths, removing duplicated canvas-downscaling logic.This only affects the
@hidden, experimentalsessionReplayCanvasRecordingoption, so no deprecation/migration path is needed.Test instructions
yarn typecheckyarn test:unit --spec packages/browser-rum-core/src/domain/configuration/configuration.spec.tsyarn test:unit --spec packages/browser-rum/src/domain/record/canvas/canvasSnapshot.spec.tsyarn test:unit --spec packages/browser-rum/src/domain/record/trackers/trackCanvasCapture.spec.tsyarn test:unit --spec packages/browser-rum/src/domain/record/trackers/trackCanvasContent.spec.tsyarn test:unit --spec packages/browser-rum/src/domain/record/record.spec.tsChecklist