Skip to content

Increase frame capture quality, apply scaling after DPI normalization#55731

Closed
huntie wants to merge 2 commits intofacebook:mainfrom
huntie:export-D94256691
Closed

Increase frame capture quality, apply scaling after DPI normalization#55731
huntie wants to merge 2 commits intofacebook:mainfrom
huntie:export-D94256691

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Feb 24, 2026

Summary: Changelog: [Internal]

Updates Android screenshot capture for performance frame timings to improve image quality:

  • Fix scale factor calculation by first normalizing output size based on display density.
  • Increase (in most cases) output image size and encoding quality.

Impact

  • Output images are now net larger (depending on DPI), and have significantly more clarity.
  • Each captured frame now uses ~9x more space (vs a worst case device scaling starting point).

NOTE: These changes come with a memory tradeoff, and we may explore multi-frame sampling and a bounded buffer in future. Not a major bottleneck, even with this size increase (the bottleneck remains in expanding JS Sampling Profiler events).

Differential Revision: D94256691

@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 24, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Feb 24, 2026

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

huntie added a commit to huntie/react-native that referenced this pull request Feb 24, 2026
…facebook#55731)

Summary:

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 24, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 25, 2026
…facebook#55731)

Summary:

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 25, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 25, 2026
…facebook#55731)

Summary:

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 25, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Changelog: [Internal]

Differential Revision: D94256691
huntie added a commit to huntie/react-native that referenced this pull request Feb 25, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Changelog: [Internal]

Differential Revision: D94256691
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
@meta-codesync meta-codesync Bot closed this in e5f9f5f Feb 26, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 26, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Feb 26, 2026

This pull request has been merged in e5f9f5f.

@huntie huntie deleted the export-D94256691 branch February 26, 2026 18:35
zoontek pushed a commit to zoontek/react-native that referenced this pull request Mar 9, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Updates Android screenshot capture for performance frame timings to improve image quality:

- Fix scale factor calculation by first normalizing output size based on display density.
- Increase (in most cases) output image size and encoding quality.

**Impact**

- Output images are now net larger (depending on DPI), and have significantly more clarity.
- Each captured frame now uses **~9x more space** (vs a worst case device scaling starting point).

NOTE: These changes come with a memory tradeoff, and we may explore multi-frame sampling and a bounded buffer in future. Not a major bottleneck, even with this size increase (the bottleneck remains in expanding JS Sampling Profiler events).

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D94256691

fbshipit-source-id: 91f3610f5a5ac10a9806c07c21c38b30599b93de
huntie added a commit to huntie/react-native that referenced this pull request Mar 31, 2026
…facebook#55731)

Summary:
Pull Request resolved: facebook#55731

Updates Android screenshot capture for performance frame timings to improve image quality:

- Fix scale factor calculation by first normalizing output size based on display density.
- Increase (in most cases) output image size and encoding quality.

**Impact**

- Output images are now net larger (depending on DPI), and have significantly more clarity.
- Each captured frame now uses **~9x more space** (vs a worst case device scaling starting point).

NOTE: These changes come with a memory tradeoff, and we may explore multi-frame sampling and a bounded buffer in future. Not a major bottleneck, even with this size increase (the bottleneck remains in expanding JS Sampling Profiler events).

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D94256691

fbshipit-source-id: 91f3610f5a5ac10a9806c07c21c38b30599b93de
huntie pushed a commit to huntie/react-native that referenced this pull request Apr 8, 2026
Backports some CDP Performance features and stability improvements to `0.83-stable`.

This includes:
- Remaining implementation of Frame Timings and screenshot capture in performance traces (Android)
- New support for Frame Timings and screenshot capture on iOS
- Optimisations to trace chunk generation, memory usage during performance recording
- `Page.captureScreenshot` (Android, iOS)

All features remain gated behind feature flags (`fuseboxFrameRecordingEnabled`, `fuseboxScreenshotCaptureEnabled`).

**Commits applied**

- Define TracingCategory enum (facebook#54377) bd6c6bf
- Use TracingCategory in TraceEvent (facebook#54378) ce60f27
- Simple parser for serialized tracing categories (facebook#54379) 62275b6
- Propagate tracing categories to recording state (facebook#54380) 3841ef0
- Re-land "Revert D85999774: [rn][android] Add FrameTiming module" (facebook#54502) 85905ad
- Add screenshot category (facebook#54537) 5d9cb80
- Define HostTargetTracingDelegate (facebook#54622) be0dae0
- Define TracingDelegate for Android Host (facebook#54628) a212e95
- Use new API for tracing state on Android (facebook#54629) 532d0be
- Internalize TracingState interface (facebook#54631) 58ec261
- Move TracingState interfaces to inspector package (facebook#54632) 10d0d99
- Rename values of TracingState enum (facebook#54630) be94707
- FrameTiming module to subscribe to Inspector tracing lifecycle (facebook#54633) 04ee02b
- Clarify HostTracingProfile and HostTraceRecordingState (facebook#54677) ec92f12
- Introduce TimeWindowedBuffer (facebook#54679) d6ee54f
- Keep tracing time window on TraceRecordingState (facebook#54673) e651563
- Define FrameTimingSequence (facebook#54674) 5b7d92f
- Define an endpoint on HostTarget to capture frame timings (facebook#54672) f469aa3
- Extract frame trace events construction logic (facebook#54675) 57973fa
- Define serializers for frame timings as part of HostTargetTracingProfile (facebook#54681) 587d360
- Propagate Frames data through Host (facebook#54671) 26ff069
- Cleanup no longer used jni layer for frame timings (facebook#54678) 9ba4ce6
- Fix screenshot typo (facebook#54742) 52186a3
- Add optional screenshot argument to FrameTimingSequence (facebook#54743) 57c29fc
- Frame screenshot event generation (facebook#54744) b447d26
- Frame screenshots capture implementation (facebook#54745) f3c9a8d
- BeginDrawing: INTENDED_VSYNC_TIMESTAMP -> VSYNC_TIMESTAMP (facebook#54765) 9221772
- Add frames category (facebook#54768) 31a0c9a
- Specify correct category for SetLayerTreeId event (facebook#54769) cd055e9
- Reduce the screenshots size (facebook#54800) e4a5a56
- Remove Commit from FrameTimingSequence (facebook#54779) 39f7703
- Fix potential bitmap leaks in FrameTimingsObserver (facebook#55652) 3918dd1
- Capture initial screenshot when starting frame timing trace (facebook#55720) 863f5c0
- Refactor FrameTimingsObserver for multi-activity support (facebook#55740) 8230f3b
- Reorder FrameTimingsObserver methods (facebook#55743) f56b295
- Increase frame capture quality, apply scaling after DPI normalization (facebook#55731) e5f9f5f
- Fix FrameTimingsObverver to initiate PixelCopy on main thread (facebook#55744) d552f2a
- Fix bitmap reuse race condition in FrameTimingsObserver (facebook#55745) 3924768
- Fix trailing frame capture after recording ended (facebook#55704) 47684ca
- Move base64Encode into react/utils (facebook#55873) 422770d
- Move screenshot Base64 encoding to trace serialization (facebook#55803) dc4c36e
- Restore inspector addPage listener callback (facebook#55925) 8c763fc
- Add tracing helper functions for RNDT traces in C++ and Kotlin (facebook#55935) 4f3f536
- Introduce fuseboxFrameRecordingEnabled flag, gate existing code (facebook#55941) 1aa7a32
- Implement Performance frames and screenshots on iOS (facebook#56015) 64a1a10
- Add pixel diffing to RCTFrameTimingsObserver (facebook#56043) 9d231af
- Add dynamic sampling to frame screenshots (facebook#56048) d309cda
- Switch trace event chunks from event count to size based (facebook#56080) d3b33f5
- Increase trace screenshot scale factor to 1x (facebook#56079) 972a30d
- Add Page.captureScreenshot CDP support (facebook#56307) 77332d2
- Fix data race on PerformanceObserver entry buffer (facebook#56352) 5eb1ca1
- [LOCAL] Remove stale frame event code from PerformanceTracer
- [LOCAL] Update Podfile.lock
huntie pushed a commit to huntie/react-native that referenced this pull request Apr 8, 2026
Backports some CDP Performance features and stability improvements to `0.83-stable`.

This includes:
- Remaining implementation of Frame Timings and screenshot capture in performance traces (Android)
- New support for Frame Timings and screenshot capture on iOS
- Optimisations to trace chunk generation, memory usage during performance recording
- `Page.captureScreenshot` (Android, iOS)

All features remain gated behind feature flags (`fuseboxFrameRecordingEnabled`, `fuseboxScreenshotCaptureEnabled`).

**Commits applied**

- Define TracingCategory enum (facebook#54377) bd6c6bf
- Use TracingCategory in TraceEvent (facebook#54378) ce60f27
- Simple parser for serialized tracing categories (facebook#54379) 62275b6
- Propagate tracing categories to recording state (facebook#54380) 3841ef0
- Re-land "Revert D85999774: [rn][android] Add FrameTiming module" (facebook#54502) 85905ad
- Add screenshot category (facebook#54537) 5d9cb80
- Define HostTargetTracingDelegate (facebook#54622) be0dae0
- Define TracingDelegate for Android Host (facebook#54628) a212e95
- Use new API for tracing state on Android (facebook#54629) 532d0be
- Internalize TracingState interface (facebook#54631) 58ec261
- Move TracingState interfaces to inspector package (facebook#54632) 10d0d99
- Rename values of TracingState enum (facebook#54630) be94707
- FrameTiming module to subscribe to Inspector tracing lifecycle (facebook#54633) 04ee02b
- Clarify HostTracingProfile and HostTraceRecordingState (facebook#54677) ec92f12
- Introduce TimeWindowedBuffer (facebook#54679) d6ee54f
- Keep tracing time window on TraceRecordingState (facebook#54673) e651563
- Define FrameTimingSequence (facebook#54674) 5b7d92f
- Define an endpoint on HostTarget to capture frame timings (facebook#54672) f469aa3
- Extract frame trace events construction logic (facebook#54675) 57973fa
- Define serializers for frame timings as part of HostTargetTracingProfile (facebook#54681) 587d360
- Propagate Frames data through Host (facebook#54671) 26ff069
- Cleanup no longer used jni layer for frame timings (facebook#54678) 9ba4ce6
- Fix screenshot typo (facebook#54742) 52186a3
- Add optional screenshot argument to FrameTimingSequence (facebook#54743) 57c29fc
- Frame screenshot event generation (facebook#54744) b447d26
- Frame screenshots capture implementation (facebook#54745) f3c9a8d
- BeginDrawing: INTENDED_VSYNC_TIMESTAMP -> VSYNC_TIMESTAMP (facebook#54765) 9221772
- Add frames category (facebook#54768) 31a0c9a
- Specify correct category for SetLayerTreeId event (facebook#54769) cd055e9
- Reduce the screenshots size (facebook#54800) e4a5a56
- Remove Commit from FrameTimingSequence (facebook#54779) 39f7703
- Fix potential bitmap leaks in FrameTimingsObserver (facebook#55652) 3918dd1
- Capture initial screenshot when starting frame timing trace (facebook#55720) 863f5c0
- Refactor FrameTimingsObserver for multi-activity support (facebook#55740) 8230f3b
- Reorder FrameTimingsObserver methods (facebook#55743) f56b295
- Increase frame capture quality, apply scaling after DPI normalization (facebook#55731) e5f9f5f
- Fix FrameTimingsObverver to initiate PixelCopy on main thread (facebook#55744) d552f2a
- Fix bitmap reuse race condition in FrameTimingsObserver (facebook#55745) 3924768
- Fix trailing frame capture after recording ended (facebook#55704) 47684ca
- Move base64Encode into react/utils (facebook#55873) 422770d
- Move screenshot Base64 encoding to trace serialization (facebook#55803) dc4c36e
- Restore inspector addPage listener callback (facebook#55925) 8c763fc
- Add tracing helper functions for RNDT traces in C++ and Kotlin (facebook#55935) 4f3f536
- Introduce fuseboxFrameRecordingEnabled flag, gate existing code (facebook#55941) 1aa7a32
- Implement Performance frames and screenshots on iOS (facebook#56015) 64a1a10
- Add pixel diffing to RCTFrameTimingsObserver (facebook#56043) 9d231af
- Add dynamic sampling to frame screenshots (facebook#56048) d309cda
- Switch trace event chunks from event count to size based (facebook#56080) d3b33f5
- Increase trace screenshot scale factor to 1x (facebook#56079) 972a30d
- Add Page.captureScreenshot CDP support (facebook#56307) 77332d2
- Fix data race on PerformanceObserver entry buffer (facebook#56352) 5eb1ca1
- [LOCAL] Remove stale frame event code from PerformanceTracer
- [LOCAL] Update Podfile.lock
huntie added a commit to huntie/react-native that referenced this pull request Apr 9, 2026
Backports some CDP Performance features and stability improvements to `0.83-stable`.

This includes:
- Remaining implementation of Frame Timings and screenshot capture in performance traces (Android)
- New support for Frame Timings and screenshot capture on iOS
- Optimisations to trace chunk generation, memory usage during performance recording
- `Page.captureScreenshot` (Android, iOS)

All features remain gated behind feature flags (`fuseboxFrameRecordingEnabled`, `fuseboxScreenshotCaptureEnabled`).

**Commits applied**

- Define TracingCategory enum (facebook#54377) bd6c6bf
- Use TracingCategory in TraceEvent (facebook#54378) ce60f27
- Simple parser for serialized tracing categories (facebook#54379) 62275b6
- Propagate tracing categories to recording state (facebook#54380) 3841ef0
- Re-land "Revert D85999774: [rn][android] Add FrameTiming module" (facebook#54502) 85905ad
- Add screenshot category (facebook#54537) 5d9cb80
- Define HostTargetTracingDelegate (facebook#54622) be0dae0
- Define TracingDelegate for Android Host (facebook#54628) a212e95
- Use new API for tracing state on Android (facebook#54629) 532d0be
- Internalize TracingState interface (facebook#54631) 58ec261
- Move TracingState interfaces to inspector package (facebook#54632) 10d0d99
- Rename values of TracingState enum (facebook#54630) be94707
- FrameTiming module to subscribe to Inspector tracing lifecycle (facebook#54633) 04ee02b
- Clarify HostTracingProfile and HostTraceRecordingState (facebook#54677) ec92f12
- Introduce TimeWindowedBuffer (facebook#54679) d6ee54f
- Keep tracing time window on TraceRecordingState (facebook#54673) e651563
- Define FrameTimingSequence (facebook#54674) 5b7d92f
- Define an endpoint on HostTarget to capture frame timings (facebook#54672) f469aa3
- Extract frame trace events construction logic (facebook#54675) 57973fa
- Define serializers for frame timings as part of HostTargetTracingProfile (facebook#54681) 587d360
- Propagate Frames data through Host (facebook#54671) 26ff069
- Cleanup no longer used jni layer for frame timings (facebook#54678) 9ba4ce6
- Fix screenshot typo (facebook#54742) 52186a3
- Add optional screenshot argument to FrameTimingSequence (facebook#54743) 57c29fc
- Frame screenshot event generation (facebook#54744) b447d26
- Frame screenshots capture implementation (facebook#54745) f3c9a8d
- BeginDrawing: INTENDED_VSYNC_TIMESTAMP -> VSYNC_TIMESTAMP (facebook#54765) 9221772
- Add frames category (facebook#54768) 31a0c9a
- Specify correct category for SetLayerTreeId event (facebook#54769) cd055e9
- Reduce the screenshots size (facebook#54800) e4a5a56
- Remove Commit from FrameTimingSequence (facebook#54779) 39f7703
- Fix potential bitmap leaks in FrameTimingsObserver (facebook#55652) 3918dd1
- Capture initial screenshot when starting frame timing trace (facebook#55720) 863f5c0
- Refactor FrameTimingsObserver for multi-activity support (facebook#55740) 8230f3b
- Reorder FrameTimingsObserver methods (facebook#55743) f56b295
- Increase frame capture quality, apply scaling after DPI normalization (facebook#55731) e5f9f5f
- Fix FrameTimingsObverver to initiate PixelCopy on main thread (facebook#55744) d552f2a
- Fix bitmap reuse race condition in FrameTimingsObserver (facebook#55745) 3924768
- Fix trailing frame capture after recording ended (facebook#55704) 47684ca
- Move base64Encode into react/utils (facebook#55873) 422770d
- Move screenshot Base64 encoding to trace serialization (facebook#55803) dc4c36e
- Restore inspector addPage listener callback (facebook#55925) 8c763fc
- Add tracing helper functions for RNDT traces in C++ and Kotlin (facebook#55935) 4f3f536
- Introduce fuseboxFrameRecordingEnabled flag, gate existing code (facebook#55941) 1aa7a32
- Implement Performance frames and screenshots on iOS (facebook#56015) 64a1a10
- Add pixel diffing to RCTFrameTimingsObserver (facebook#56043) 9d231af
- Add dynamic sampling to frame screenshots (facebook#56048) d309cda
- Switch trace event chunks from event count to size based (facebook#56080) d3b33f5
- Increase trace screenshot scale factor to 1x (facebook#56079) 972a30d
- Add Page.captureScreenshot CDP support (facebook#56307) 77332d2
- Fix data race on PerformanceObserver entry buffer (facebook#56352) 5eb1ca1
- Add dynamic sampling to frame screenshots (facebook#56135) e0d1e29
- Increase trace screenshot scale factor to 1x (facebook#56136) 90e02fa
- Add missing debugger define for React-RuntimeApple (facebook#56397)
- [LOCAL] Remove stale frame event code from PerformanceTracer
- [LOCAL] Update Podfile.lock
gabrieldonadel pushed a commit that referenced this pull request Apr 13, 2026
Backports some CDP Performance features and stability improvements to `0.83-stable`.

This includes:
- Remaining implementation of Frame Timings and screenshot capture in performance traces (Android)
- New support for Frame Timings and screenshot capture on iOS
- Optimisations to trace chunk generation, memory usage during performance recording
- `Page.captureScreenshot` (Android, iOS)

All features remain gated behind feature flags (`fuseboxFrameRecordingEnabled`, `fuseboxScreenshotCaptureEnabled`).

**Commits applied**

- Define TracingCategory enum (#54377) bd6c6bf
- Use TracingCategory in TraceEvent (#54378) ce60f27
- Simple parser for serialized tracing categories (#54379) 62275b6
- Propagate tracing categories to recording state (#54380) 3841ef0
- Re-land "Revert D85999774: [rn][android] Add FrameTiming module" (#54502) 85905ad
- Add screenshot category (#54537) 5d9cb80
- Define HostTargetTracingDelegate (#54622) be0dae0
- Define TracingDelegate for Android Host (#54628) a212e95
- Use new API for tracing state on Android (#54629) 532d0be
- Internalize TracingState interface (#54631) 58ec261
- Move TracingState interfaces to inspector package (#54632) 10d0d99
- Rename values of TracingState enum (#54630) be94707
- FrameTiming module to subscribe to Inspector tracing lifecycle (#54633) 04ee02b
- Clarify HostTracingProfile and HostTraceRecordingState (#54677) ec92f12
- Introduce TimeWindowedBuffer (#54679) d6ee54f
- Keep tracing time window on TraceRecordingState (#54673) e651563
- Define FrameTimingSequence (#54674) 5b7d92f
- Define an endpoint on HostTarget to capture frame timings (#54672) f469aa3
- Extract frame trace events construction logic (#54675) 57973fa
- Define serializers for frame timings as part of HostTargetTracingProfile (#54681) 587d360
- Propagate Frames data through Host (#54671) 26ff069
- Cleanup no longer used jni layer for frame timings (#54678) 9ba4ce6
- Fix screenshot typo (#54742) 52186a3
- Add optional screenshot argument to FrameTimingSequence (#54743) 57c29fc
- Frame screenshot event generation (#54744) b447d26
- Frame screenshots capture implementation (#54745) f3c9a8d
- BeginDrawing: INTENDED_VSYNC_TIMESTAMP -> VSYNC_TIMESTAMP (#54765) 9221772
- Add frames category (#54768) 31a0c9a
- Specify correct category for SetLayerTreeId event (#54769) cd055e9
- Reduce the screenshots size (#54800) e4a5a56
- Remove Commit from FrameTimingSequence (#54779) 39f7703
- Fix potential bitmap leaks in FrameTimingsObserver (#55652) 3918dd1
- Capture initial screenshot when starting frame timing trace (#55720) 863f5c0
- Refactor FrameTimingsObserver for multi-activity support (#55740) 8230f3b
- Reorder FrameTimingsObserver methods (#55743) f56b295
- Increase frame capture quality, apply scaling after DPI normalization (#55731) e5f9f5f
- Fix FrameTimingsObverver to initiate PixelCopy on main thread (#55744) d552f2a
- Fix bitmap reuse race condition in FrameTimingsObserver (#55745) 3924768
- Fix trailing frame capture after recording ended (#55704) 47684ca
- Move base64Encode into react/utils (#55873) 422770d
- Move screenshot Base64 encoding to trace serialization (#55803) dc4c36e
- Restore inspector addPage listener callback (#55925) 8c763fc
- Add tracing helper functions for RNDT traces in C++ and Kotlin (#55935) 4f3f536
- Introduce fuseboxFrameRecordingEnabled flag, gate existing code (#55941) 1aa7a32
- Implement Performance frames and screenshots on iOS (#56015) 64a1a10
- Add pixel diffing to RCTFrameTimingsObserver (#56043) 9d231af
- Add dynamic sampling to frame screenshots (#56048) d309cda
- Switch trace event chunks from event count to size based (#56080) d3b33f5
- Increase trace screenshot scale factor to 1x (#56079) 972a30d
- Add Page.captureScreenshot CDP support (#56307) 77332d2
- Fix data race on PerformanceObserver entry buffer (#56352) 5eb1ca1
- Add dynamic sampling to frame screenshots (#56135) e0d1e29
- Increase trace screenshot scale factor to 1x (#56136) 90e02fa
- Add missing debugger define for React-RuntimeApple (#56397)
- [LOCAL] Remove stale frame event code from PerformanceTracer
- [LOCAL] Update Podfile.lock
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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants