This is due to the automatic image viewer function.
Turn off the automatic image viewer function. The automatic viewer function is driven by the foreground thread in the sample code and it will interfere with the recording thread. The automatic viewer function should be implemented in a separate thread (see FSViewer sample).