Skip to content

Investigate childCount > 0 as readiness indicator for screenshot - #111

Merged
EmilioBejasa merged 1 commit into
mainfrom
investigate-predraw-listener
Apr 9, 2026
Merged

EmilioBejasa merged 1 commit into
mainfrom
investigate-predraw-listener

Conversation

@EmilioBejasa

Copy link
Copy Markdown
Contributor

Summary

  • Adds childCountTest to verify that Fabric mounts children into the surface view when using WindowAttachment.dispatchAttach + onHostResume + surface.start()
  • Adds childCountScreenshotTest to verify that polling until childCount > 0, then re-running layout, produces a non-blank screenshot
  • Investigates OnPreDrawListener as an alternative readiness signal — ruled out because it requires a real draw pipeline, which WindowAttachment.dispatchAttach does not provide

Why

Before building a reusable screenshot testing library, we need a reliable indicator that a React Native view is ready to be snapshotted. This PR establishes that childCount > 0 (Fabric has mounted children) followed by a re-layout pass is a viable signal.

Test plan

  • childCountTest passes — confirms readiness signal is reachable
  • childCountScreenshotTest passes — confirms signal produces a non-blank screenshot ("Hello" visible in top-left)

🤖 Generated with Claude Code

…ess indicator

Explores using childCount > 0 as the signal that Fabric has mounted
children, followed by a re-layout pass before snapping the screenshot.
Also investigates OnPreDrawListener as an alternative, which does not
work with WindowAttachment.dispatchAttach (no real draw pipeline).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
detacher = WindowAttachment.dispatchAttach(view)
app.reactHost.onHostResume(null)
ViewHelpers.setupView(view).setExactWidthPx(1080).setExactHeightPx(1920).layout()
surface.start()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add an assertion here to demonstrate that childCount == 0. In your next PR, try to create a unit test that just gets childCount > 0. Not a screenshot test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good!

@EmilioBejasa
EmilioBejasa marked this pull request as ready for review April 9, 2026 19:58
@EmilioBejasa
EmilioBejasa merged commit 7a2ab4b into main Apr 9, 2026
1 of 2 checks passed
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