Skip to content

fix: add extra validity checks during snapshots#423

Open
ioannisj wants to merge 4 commits intomainfrom
fix/crash-when-generating-snapshot
Open

fix: add extra validity checks during snapshots#423
ioannisj wants to merge 4 commits intomainfrom
fix/crash-when-generating-snapshot

Conversation

@ioannisj
Copy link
Collaborator

💡 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

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.
  • If there are related changes in the core package, I've already released them, or I'll release them before this one.

@ioannisj ioannisj requested a review from a team as a code owner February 18, 2026 08:13
val window = windowRef.get() ?: return

// Check view is still valid before any access to avoid native crashes
if (!view.isAliveAndAttachedToWindow()) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toScreenshotWireframe calls view.isVisible(), maybe toScreenshotWireframe should call isAliveAndAttachedToWindow instead? can you test this out?


// Check view is still valid before any access to avoid native crashes
if (!view.isAliveAndAttachedToWindow()) return
if (view.width <= 0 || view.height <= 0) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Comment on lines +410 to +411
// Check window still has valid decor view
if (window.peekDecorView() == null) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think thats covered by L403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments