Skip to content

Commit

Permalink
Fix #22581 by introducing an artificial delay (#22601) (#22716)
Browse files Browse the repository at this point in the history
Introduce a delay into reports to allow visualizations time to appear in the DOM. This is intended as a temporary (and hacky) workaround until we come up with a more robust way to determine that all of the visualizations on the page are ready for capture.
  • Loading branch information
chrisdavies authored Sep 5, 2018
1 parent b8ad4ce commit f04a760
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ export function screenshotsObservableFactory(server) {
}
}

return Promise.all(renderedTasks);
// The renderComplete fires before the visualizations are in the DOM, so
// we wait for the event loop to flush before telling reporting to continue. This
// seems to correct a timing issue that was causing reporting to occasionally
// capture the first visualization before it was actually in the DOM.
const hackyWaitForVisualizations = () => new Promise(r => setTimeout(r, 100));

return Promise.all(renderedTasks).then(hackyWaitForVisualizations);
},
args: [layout.selectors.renderComplete, captureConfig.loadDelay],
awaitPromise: true,
Expand Down

0 comments on commit f04a760

Please sign in to comment.