← Back to Pull requests

feat(sr): add high-fidelity text capture mode #1290

Closed
unknown closed this pull request without merging on Nov 12, 2026 08:49 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 14:00 UTC
Author

What and why?

In Session Replay, Flutter text is sent as text wireframes, and the web player draws it with fonts installed in the viewer's browser. Custom fonts, font weights, letter spacing and mixed styles get lost, and paragraphs often wrap onto a different number of lines than on the device. The native SDKs have the same limitation: they send a fixed font list, and the player draws text 1px smaller than recorded, with a tight line height.

This PR adds an opt-in high-fidelity text capture mode that sends each paragraph as an image of exactly what Flutter drew on the device:

DatadogSessionReplayConfiguration(
  replaySampleRate: 100,
  textCaptureMode: TextCaptureMode.highFidelity, // default: TextCaptureMode.standard
)

  • standard (default) keeps today's behavior, so existing users see no change.

  • highFidelity makes the replay match the device: custom fonts, weights, italics, mixed styles, ellipsis and line breaks.
  • How?

  • Rasterizing: TextElementRecorder paints the already laid-out RenderParagraph offscreen during the capture walk and reads the pixels back in process(), one paragraph at a time, then uploads them through the existing image pipeline. Inline WidgetSpan children are skipped and recorded as their own nodes. If painting or uploading fails, the paragraph is sent as text.

  • Painted area: the image covers what the paragraph actually paints: text running past its box with TextOverflow.visible, shadows, and a glyph margin for text that isn't upright Latin in a platform default font. Clipped overflow keeps the layout box.

  • Privacy: maskAll text and text fields (EditableText) are always sent as text.

  • Cost controls (text and icons):

  • - an LRU cache keyed by what was drawn, including the current selection and inline widget layout; cleared when the available fonts change (e.g. a runtime-loaded font)
    - images reused during transform animations
    - maxImagePixelBudget / imageDownscaling followed like images: over budget, text falls back to text and icons show "Large Icon", or both are drawn smaller with downscaling enabled
  • Refactor: code shared by the image, icon and text recorders moves to raster_resources.dart. Image caching is unchanged.

  • Trade-offs:

  • - each new or changed paragraph is uploaded as an image, so screens with fast-changing text upload more
    - Related fixes:
    - computeDiff replaces a wireframe whose type changes (e.g. image to masked text) instead of skipping it, which also fixes images and icons on develop
    - maxImagePixelBudget values below 1 are replaced by the default with a warning

    Review checklist

  • This pull request has appropriate unit and / or integration tests

  • This pull request references a Github or JIRA issue — PANA-10062
  • Diff: 356 lines (+267 / -89) across 4 files Reviewer: fuzzybinary Review duration: 8329m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 356 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.352
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1290"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%