Skip to content

Fix bitmap reuse race condition in FrameTimingsObserver#55745

Open
huntie wants to merge 4 commits intofacebook:mainfrom
huntie:export-D94368260
Open

Fix bitmap reuse race condition in FrameTimingsObserver#55745
huntie wants to merge 4 commits intofacebook:mainfrom
huntie:export-D94368260

Conversation

@huntie
Copy link
Member

@huntie huntie commented Feb 25, 2026

Summary:
The shared bitmapBuffer could be overwritten by a new PixelCopy request on the main thread while a previous frame's encoding coroutine was still reading from it. Each frame now gets its own bitmap, recycled after encoding.

NOTE: This will come at a slight perf cost (allocating extra new bitmaps in memory), for the tradeoff of correctness.

Changelog: [Internal]

Differential Revision: D94368260

Summary:
Small refactor — locate public methods first, sort private methods in call order.

Changelog: [Internal]

Differential Revision: D94366535
…facebook#55731)

Summary:

Changelog: [Internal]

Differential Revision: D94256691
Summary:
Previously, screenshot capture was initiated on a background thread, so `PixelCopy` could run during a later frame than the one being reported. Screenshots now correctly correspond to their frame metrics callback.

Changelog: [Internal]

Differential Revision: D94368259
Summary:
The shared `bitmapBuffer` could be overwritten by a new `PixelCopy` request on the main thread while a previous frame's encoding coroutine was still reading from it. Each frame now gets its own bitmap, recycled after encoding.

NOTE: This will come at a slight perf cost (allocating extra new bitmaps in memory), for the tradeoff of correctness.

Changelog: [Internal]

Differential Revision: D94368260
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 25, 2026
@meta-codesync
Copy link

meta-codesync bot commented Feb 25, 2026

@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94368260.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants