Commit 001f3ad
fix(replay): Avoid windowLocation race and bitmap leak in SurfaceView capture
Address two issues flagged by review:
1. windowLocation race — root.getLocationOnScreen(windowLocation) ran on the
main thread, but compositeSurfaceViewsAndMask read windowLocation[0]/[1]
later from the executor thread. If a new capture cycle started before the
compositor ran, the field was overwritten and SurfaceView pixels would
composite at the wrong offset. Snapshot into locals (windowX/windowY) at
capture time and pass them through, matching the existing svLocation →
capturedX/capturedY pattern.
2. Bitmap leak when isClosed in SurfaceView callback — when the strategy
closed mid-capture, the path recycled the in-flight svBitmap but skipped
onCaptureComplete(), so remaining never reached zero and any sibling
bitmaps already stored in captures[] leaked until GC. Now still drive the
completion latch on the closed path, and have the compositor's
early-return path recycle leftover captures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bd86dea commit 001f3ad
1 file changed
Lines changed: 21 additions & 3 deletions
File tree
- sentry-android-replay/src/main/java/io/sentry/android/replay/screenshot
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
160 | 162 | | |
| 163 | + | |
| 164 | + | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
166 | 170 | | |
167 | | - | |
| 171 | + | |
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
| |||
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
194 | 201 | | |
195 | 202 | | |
196 | 203 | | |
| |||
214 | 221 | | |
215 | 222 | | |
216 | 223 | | |
| 224 | + | |
| 225 | + | |
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
221 | 230 | | |
| 231 | + | |
222 | 232 | | |
223 | 233 | | |
224 | 234 | | |
| |||
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
237 | | - | |
238 | | - | |
| 247 | + | |
| 248 | + | |
239 | 249 | | |
240 | 250 | | |
241 | 251 | | |
| |||
247 | 257 | | |
248 | 258 | | |
249 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
250 | 268 | | |
251 | 269 | | |
252 | 270 | | |
| |||
0 commit comments