You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of writing this text, it is currently possible to run into deadlock when stopping recording thread.
In PR #1505, a new method of capturing images from cameras and cameras' positions in sync with each other was introduced: the recording thread is adding a delegate function to call on a GameThread whenever drawing ends (UGameViewportClient::OnEndDraw). This code is in Unreal/Plugins/AirSim/Source/RenderRequest.cpp.
FRecordingThread::stopRecording is always called in the GameThread. So whenever it is called, GameThread starts waiting for FRecordingThread to finish. The issue is, FRecordingThread can be waiting for drawing to end, and drawing is happening on a GameThread. So the situation is possible, when GameThread is waiting for FRecordingThread to finish, while FRecordingThread is waiting for a specific event on the GameThread to fire — a deadlock.
The result is, obviously enough, that UE4 app freezes completely and stops reacting to any sort of input and can only be closed by killing the process. In our project, we start and stop recording programmatically in an endless loop, so it's only a matter of time when this occurs and the simulation needs to be restarted manually. This can also occur when Play-In-Editor session is interrupted by pressing "Stop" button from inside UE4 editor or when exit command is executed in UE4 console.
Admittedly, AirSim architecture does not seem to be designed with this in mind, because stopRecording is not exposed to the code outside AirSim. We get around this by firing USimHUDWidget::onToggleRecordingButtonClick on USimHUDWidget instance in blueprints (simulating a button press on the "Toggle Recording" button in the lower right corner).
The problem is kind of hard to reproduce by its nature. However, if you load a heavy enough map in UE4, set RecordInterval very low (0.1, for instance), and start and stop recording in an endless loop (for example, starting a recording, waiting for 3 seconds, stopping it, waiting for 1 second, rinse, repeat), deadlock can occur within minutes of running. But, repeating myself, this occurs sooner or later regardless of all these parameters.
The text was updated successfully, but these errors were encountered:
As of writing this text, it is currently possible to run into deadlock when stopping recording thread.
In PR #1505, a new method of capturing images from cameras and cameras' positions in sync with each other was introduced: the recording thread is adding a delegate function to call on a GameThread whenever drawing ends (
UGameViewportClient::OnEndDraw
). This code is inUnreal/Plugins/AirSim/Source/RenderRequest.cpp
.Problems begin when we want to stop the recording. This is done by calling
FRecordingThread::stopRecording
, which callsFRecordingThread::EnsureCompletion
, which sends a signal to recording thread to stop execution and then waits for it to actually finish.FRecordingThread::stopRecording
is always called in the GameThread. So whenever it is called, GameThread starts waiting for FRecordingThread to finish. The issue is, FRecordingThread can be waiting for drawing to end, and drawing is happening on a GameThread. So the situation is possible, when GameThread is waiting for FRecordingThread to finish, while FRecordingThread is waiting for a specific event on the GameThread to fire — a deadlock.The result is, obviously enough, that UE4 app freezes completely and stops reacting to any sort of input and can only be closed by killing the process. In our project, we start and stop recording programmatically in an endless loop, so it's only a matter of time when this occurs and the simulation needs to be restarted manually. This can also occur when Play-In-Editor session is interrupted by pressing "Stop" button from inside UE4 editor or when
exit
command is executed in UE4 console.Admittedly, AirSim architecture does not seem to be designed with this in mind, because
stopRecording
is not exposed to the code outside AirSim. We get around this by firingUSimHUDWidget::onToggleRecordingButtonClick
onUSimHUDWidget
instance in blueprints (simulating a button press on the "Toggle Recording" button in the lower right corner).The problem is kind of hard to reproduce by its nature. However, if you load a heavy enough map in UE4, set
RecordInterval
very low (0.1, for instance), and start and stop recording in an endless loop (for example, starting a recording, waiting for 3 seconds, stopping it, waiting for 1 second, rinse, repeat), deadlock can occur within minutes of running. But, repeating myself, this occurs sooner or later regardless of all these parameters.The text was updated successfully, but these errors were encountered: