Commit 9ff647c
Add dynamic sampling to frame screenshots
Summary:
Update Android frame screenshot processing to skip frames when encoding is backed up, ensuring we capture at most every 5th frame when pending work exists.
**Motivation**: Prevents truncated trace data on slower devices (e.g. missing screenshots for the last 1/3 of the trace), with the tradeoff of some intermediate frame data loss (note: we **do** emit a frame event, just without a visual snapshot).
NOTE: This still does not yet solve crashes (OkHttp network chunk size overflow) for heavy frame data at a high FPS on fast devices (coming next).
**Throttling logic**
- Each frame increments `framesSinceLastEnqueue`.
- If there are pending frames AND we haven't reached the minimum sample rate (5), the frame is skipped.
- When a frame is enqueued, reset the counter and track it as pending.
- When processing completes (in either screenshot or non-screenshot path), decrement the pending count.
**🚧 Still under experimentation**
A `MIN_FRAME_SAMPLE_RATE` of 5 may be too destructive, in which case we will evolve this over time.
NOTE: 1 parent 19350b1 commit 9ff647c
1 file changed
Lines changed: 27 additions & 4 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector
Lines changed: 27 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| 94 | + | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
99 | 118 | | |
100 | 119 | | |
101 | 120 | | |
| 121 | + | |
102 | 122 | | |
103 | 123 | | |
104 | 124 | | |
| |||
172 | 192 | | |
173 | 193 | | |
174 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
175 | 198 | | |
176 | 199 | | |
177 | 200 | | |
| |||
0 commit comments