Title: Session Replay: consolidate window size detection onto OnLayoutChangeListener · Issue #5382 · getsentry/sentry-java · GitHub
Open Graph Title: Session Replay: consolidate window size detection onto OnLayoutChangeListener · Issue #5382 · getsentry/sentry-java
X Title: Session Replay: consolidate window size detection onto OnLayoutChangeListener · Issue #5382 · getsentry/sentry-java
Description: Summary WindowRecorder.determineWindowSize currently has two detection paths for window size changes: Synchronous: if the root already has size at registration time, compare and emit immediately. Deferred (OnPreDrawListener): if the root...
Open Graph Description: Summary WindowRecorder.determineWindowSize currently has two detection paths for window size changes: Synchronous: if the root already has size at registration time, compare and emit immediately. D...
X Description: Summary WindowRecorder.determineWindowSize currently has two detection paths for window size changes: Synchronous: if the root already has size at registration time, compare and emit immediately. D...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/5382
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Session Replay: consolidate window size detection onto OnLayoutChangeListener","articleBody":"## Summary\n\n`WindowRecorder.determineWindowSize` currently has two detection paths for window size changes:\n\n1. **Synchronous**: if the root already has size at registration time, compare and emit immediately.\n2. **Deferred** (`OnPreDrawListener`): if the root has no size yet (typical — Curtains fires `onRootViewsChanged` before the first traversal), register a listener that re-checks on every pre-draw and removes itself once size is known.\n\n[#5333](https://github.com/getsentry/sentry-java/pull/5333) added a third path — an `OnLayoutChangeListener` per tracked root — to detect same-root resizes for activities with `configChanges` (Unity, video players). This listener strictly subsumes the `OnPreDrawListener` path: it fires on the first `View.layout(0, 0, W, H)` (bounds differ from the initial 0/0/0/0), which happens on the same Choreographer frame but before draw.\n\n## Proposed change\n\nReplace the `OnPreDrawListener` path with the `OnLayoutChangeListener`, keeping the synchronous check for the rare case where the root already has size at add time. This would:\n\n- Remove the dual-listener setup (simpler code, one mechanism instead of two).\n- Eliminate the per-preDraw iteration that checks `hasSize()` and `root == currentRoot` on every draw until size is known.\n- Unify initial detection and subsequent resize detection into a single listener.\n\nThe `OnLayoutChangeListener` already has the latest-root guard (`v != rootViews.lastOrNull()?.get()` → skip), matching the `OnPreDrawListener`'s existing `root != currentRoot` guard.\n\n## Why it wasn't done in #5333\n\nThe refactor changes behavior for all apps, not just `configChanges` activities. It was kept out of scope to limit regression risk in the SurfaceView capture PR.","author":{"url":"https://github.com/romtsn","@type":"Person","name":"romtsn"},"datePublished":"2026-05-06T21:19:51Z","url":"https://github.com/getsentry/sentry-java/issues/5382"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:15b3b70e-eef4-09be-f21a-d26db0ee55ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BAC2:E7908:45CD70:62A6F1:6B047263 |
| html-safe-nonce | c7e53947a2a4f4de0db31c2c7d139555257a9ed1fcb4692de41e87f374a0b324 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUMyOkU3OTA4OjQ1Q0Q3MDo2MkE2RjE6NkIwNDcyNjMiLCJ2aXNpdG9yX2lkIjoiMTQyODY2NjA0MzI1NzM1MjgwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9a10f21c508acbc53ece21b14df0574c211a7965feabc783e04acc841e8cc4ff |
| hovercard-subject-tag | issue:4394512431 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/5382/issue_layout |
| twitter:image | https://opengraph.githubassets.com/73f331328e8971236f3905d158af46f0f13d6058bcf247862c875a81ff83ca6a/getsentry/sentry-java/issues/5382 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/73f331328e8971236f3905d158af46f0f13d6058bcf247862c875a81ff83ca6a/getsentry/sentry-java/issues/5382 |
| og:image:alt | Summary WindowRecorder.determineWindowSize currently has two detection paths for window size changes: Synchronous: if the root already has size at registration time, compare and emit immediately. D... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | romtsn |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width