Skip to content

PANA-9097: Copy bitmaps before reading them - #1440

Open
jonathanmos wants to merge 1 commit into
developfrom
jmoskovich/pana-9097/fix-sigabrt
Open

jonathanmos wants to merge 1 commit into
developfrom
jmoskovich/pana-9097/fix-sigabrt

Conversation

@jonathanmos

Copy link
Copy Markdown
Member

What does this PR do?

Session Replay's image-capture code (ReactDrawableCopier, ReactDrawablesExt) could hand out a live Bitmap reference instead of copying it, on paths where a BitmapDrawable's pixels get read on a background thread. If the bitmap's owner (e.g. Fresco) recycles it concurrently, native pixel memory is freed before isRecycled() flips — so a later native read aborts the process with an uncatchable SIGABRT.

Bitmap extraction now always produces a private copy (Bitmap.safeCopy()/safeScale()) before further processing, and ReactDrawableCopier no longer routes BitmapDrawables through the aliasing DefaultDrawableCopier. On copy/scale failure (bitmap already recycled), the code now returns null and lets the existing, already-tested ResourceResolver fallback degrade gracefully (empty ImageWireframe) instead of fabricating a blank bitmap.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@jonathanmos

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-22T11:36:46.303059Z de4f2cd Manual request
ℹ️ 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.

@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: de4f2cd432

ℹ️ 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".

@jonathanmos
jonathanmos force-pushed the jmoskovich/pana-9097/fix-sigabrt branch from de4f2cd to d2765cc Compare September 22, 2026 12:24
@jonathanmos
jonathanmos marked this pull request as ready for review September 23, 2026 08:21
Copilot AI lite review requested due to automatic review settings September 23, 2026 08:21
@jonathanmos
jonathanmos requested a review from a team as a code owner September 23, 2026 08:21

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR hardens Android Session Replay image capture by copying bitmap-backed drawables before background processing and returning null when copying fails.

Changes:

  • Adds safe bitmap copy/scale helpers.
  • Updates drawable extraction and copying to avoid shared bitmap references.
  • Adds unit tests for successful and failed copy paths.
File Description
packages/​react-native-session-replay/​android/​src/​test/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​resources/​ReactDrawableCopierTest.kt Updated as part of this pull request.
packages/​react-native-session-replay/​android/​src/​test/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​extensions/​ReactDrawablesExtTest.kt Updated as part of this pull request.
packages/​react-native-session-replay/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​resources/​ReactDrawableCopier.kt Updated as part of this pull request.
packages/​react-native-session-replay/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​extensions/​ReactDrawablesExt.kt Updated as part of this pull request.
packages/​react-native-session-replay/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​extensions/​BitmapExt.kt Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 23, 2026 11:16
@jonathanmos
jonathanmos force-pushed the jmoskovich/pana-9097/fix-sigabrt branch from d2765cc to f9eaae1 Compare September 23, 2026 11:16

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 23, 2026 11:44
@jonathanmos
jonathanmos force-pushed the jmoskovich/pana-9097/fix-sigabrt branch from f9eaae1 to 458ad2d Compare September 23, 2026 11:44

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

@sbarrio
sbarrio requested a review from cdn34dd September 24, 2026 07:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants