Skip to content

Commit b48fc50

Browse files
romtsnclaude
andcommitted
fix(replay): Ignore layout changes on non-latest root in WindowRecorder
rootViews is a stack of windows (dialogs, popups, IME). The recorder binds to the topmost root, so a background activity resizing underneath a dialog must not reconfigure the recorder — we'd otherwise allocate a bitmap sized to the activity while still recording the dialog. The latest root's correct dimensions are already picked up via determineWindowSize in the onRootViewsChanged remove path when the overlaying window dismisses. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d0b25df commit b48fc50

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sentry-android-replay/src/main/java/io/sentry/android/replay/WindowRecorder.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ internal class WindowRecorder(
167167
val height = bottom - top
168168
val oldWidth = oldRight - oldLeft
169169
val oldHeight = oldBottom - oldTop
170-
if (width != oldWidth || height != oldHeight) {
171-
determineWindowSize(v)
172-
}
170+
if (width == oldWidth && height == oldHeight) return@OnLayoutChangeListener
171+
// ignore non-latest roots so a dialog stays sized for itself, not its background activity.
172+
if (v != rootViews.lastOrNull()?.get()) return@OnLayoutChangeListener
173+
determineWindowSize(v)
173174
}
174175
rootLayoutListeners[root] = listener
175176
root.addOnLayoutChangeListener(listener)

0 commit comments

Comments
 (0)