Simulation crashes when you activate record mode
When I press the 'R' button during simulation to activate recording, it triggers an interruption point. The sequence of code that fails is:
-
UE4Editor-AirSim-Win64-DebugGame.dll!FRecordingThread::Run() Línea 67: auto response = camera_->getImage(msr::airlib::VehicleCameraBase::ImageType::Scene, false, true);
-
UE4Editor-AirSim-Win64-DebugGame.dll!VehicleCameraConnector::getImage(msr::airlib::VehicleCameraBase::ImageType image_type, bool pixels_as_float, bool compress) Línea 24: return getSceneCaptureImage(image_type, pixels_as_float, compress, false);
-
UE4Editor-AirSim-Win64-DebugGame.dll!VehicleCameraConnector::getSceneCaptureImage(msr::airlib::VehicleCameraBase::ImageType image_type, bool pixels_as_float, bool compress, bool use_safe_method) Línea 68: ImageResponse response;
-
UE4Editor-AirSim-Win64-DebugGame.dll!RenderRequest::getScreenshot(UTextureRenderTarget2D * renderTarget, TArray<unsigned char,FDefaultAllocator> & image_data_uint8, TArray<float,FDefaultAllocator> & image_data_float, bool pixels_as_float, bool compress, int & width, int & height) Línea 68:
if (!pixels_as_float) {--- if (data->width != 0 && data->height != 0) {------ if (data->compress)--------- FImageUtils::CompressImageArray(data->width, data->height, data->bmp, image_data_uint8);------ else {--------- for (const auto& item : data->bmp) {------------ image_data_uint8.Add(item.R);------------ image_data_uint8.Add(item.G);------------ image_data_uint8.Add(item.B);------------ image_data_uint8.Add(item.A);----------- }------ }
The code fails when trying to execute this last 'else'. If I edit the file RecordingThread.cpp and disable the call to getImage(), then the code fails when trying to write the log file or it outputs an empty log file.
My setup is Windows 10, Visual Studio 2015 Update 3, Unreal Engine 17.1, default environment blocks and simple flight. I can reproduce the issue following these steps:
- Clone the AirSim repository
- Open Shell for Visual Studio Developers
- Run build.cmd in the AirSim folder. It compiles without any errors.
- Run update_from_git.bat in the Unreal\Environments\Blocks folder. It updates and compiles the solution Blocks. sln without problems.
- Open Blocks.sln with Visual Studio
- With options DebugGame_Editor and Win64, run debug.
- It compiles, and launches Unreal Editor. Push play to run simulation, and push R to start recording -> interruption
I have been working with the simulator without problems for two weeks. When I installed Python tools for Visual Studio, I had issues and had to reinstall Visual Studio. After that, I can't activate the record mode anymore when launching from the Visual Studio Solution. If I instead execute tue Blocks.uproject file, it works perfectly BUT it doesn't reflects any modifications made in the code of the plugin. It seems that when you run from Unreal Editor, it runs the plugin from another directory, which is an unexpected behavior I believe.
Although it is not a very elegant solution, and it does not explain why on debug mode the code fails, you can just skip the interruption and it works.