Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Wait for idle sync before capturing screenshot
After JS calls notifyStoryReady() (end of useEffect), Fabric may still
have pending layout and mount work queued on the main thread. Taking the
screenshot immediately could capture a partially-rendered frame.

waitForIdleSync() drains the main thread's Looper before snap() runs,
ensuring all native view updates are applied first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  • Loading branch information
EmilioBejasa and claude committed Mar 18, 2026
commit 9dc196dd9f12565d057c250831904e32016a47aa
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ abstract class BaseStoryScreenshotTest {
StorybookRegistry.prepareForNextStory()
renderStory(storyName) { view ->
StorybookRegistry.awaitStoryReady(getLoadTimeoutMs())
// Wait for the main thread to drain any pending Fabric layout/mount work
// that may still be in flight after JS signals ready.
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
val screenshotName = storyInfo.id.replace("--", "_")
Screenshot.snap(view).setName(screenshotName).record()
Log.d(TAG, "Screenshot captured: $screenshotName")
Expand Down
Loading