fix: add extra validity checks during snapshots#423
Open
Conversation
marandaneto
reviewed
Feb 18, 2026
| val window = windowRef.get() ?: return | ||
|
|
||
| // Check view is still valid before any access to avoid native crashes | ||
| if (!view.isAliveAndAttachedToWindow()) return |
Member
There was a problem hiding this comment.
toScreenshotWireframe calls view.isVisible(), maybe toScreenshotWireframe should call isAliveAndAttachedToWindow instead? can you test this out?
marandaneto
reviewed
Feb 18, 2026
|
|
||
| // Check view is still valid before any access to avoid native crashes | ||
| if (!view.isAliveAndAttachedToWindow()) return | ||
| if (view.width <= 0 || view.height <= 0) return |
Member
There was a problem hiding this comment.
toScreenshotWireframe reads width and height
instead of doing this here then we just return early if its zeroed, maybe it'd even make sense to be part of "isVisible"
marandaneto
reviewed
Feb 18, 2026
Comment on lines
+410
to
+411
| // Check window still has valid decor view | ||
| if (window.peekDecorView() == null) return |
Member
There was a problem hiding this comment.
i think thats covered by L403
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Helps with ticket: https://posthoghelp.zendesk.com/agent/tickets/50523
We have not seen this in Google SDK Console but a native crash was reported during snapshot generation.
This adds a few extra checks on the view before attempting to generate a snapshot
💚 How did you test it?
📝 Checklist