Crash when using SceneCapture2D on iOS with mobile HDR disabled (w/ fix)

Hi,

There’s an assertion thrown when trying to use SceneCapture2D in iOS with mobile HDR disabled. It happens on FOpenGLDynamicRHI::RHISetRenderTargetsAndClear() at this line:

checkf(ClearValue.ColorBinding == EClearBinding::EColorBound, TEXT("Texture: %s does not have a color bound for fast clears"), *RenderTargetsInfo.ColorRenderTarget[i].Texture->GetName().GetPlainNameString());

The problem is caused by the temporary “inverted” target used when mobile HDR is disabled not having a clear value binding. [Here’s the fix diff][1], which is using the same binding as the original target.

https://github.com/KokkuGames/UnrealEngine/commit/b7d3af54fb1c5e8ac0d84b34bce2c96994d57755

Hey

Thank you for reporting this to us. I was unable to replicate this on 4.9.2 or 4.10 Preview 4. Are you able to reproduce this only in c++ projects, or both blueprint and c++? Please provide the reproduction steps so I can inform our iOS Developer of the bug.

Thanks! :slight_smile:

Did you try a development or debug build? The check() macros are compiled out in shipping builds, so it won’t crash. Also it only happens on GLES2. Metal and D3D_ES2 are not affected because neither of them need to create the temporary flipped render target.

Basically, the code path that creates the temporary render target does not assigns a clear color binding, which will fail the check when it reaches RHISetRenderTargetsAndClear().

Could you please provide me with a sample project where this is occurring? Also, which type of iOS device are you working with? Could you also provide me with from your project crashing?

[How to get off of an iOS device:][1]

Windows:

  • Open iPhonePackager (Engine/DotNET/IOS)
  • Select a uproject file (Optional)
  • Select the Advance Tools tab
  • Select Other Deployment Tools…
  • Select Backup Documents…
  • Select the IPA for the game you wish to get a log for
  • The documents directory data will then be copied to Engine/DotNET/IOS/IOS_Backups or GameDir/IOS_Backups if a uproject was selected
  • The log can then be found at IOS_Backups/Game/Saved/

Mac:

  • Open Xcode (Install Xcode if you have not already)
  • Open Window|Devices
  • Select the device you want to get the log off of
  • Select the app you want to get the log from
  • Select the gear icon under the app list
  • Select Download Container
  • Select a location for the container file
  • Navigate to the file via Finder
  • Right click and select Show Package Contents
  • Navigate to the location of the log (AppData/Documents/Game/Saved//)

A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

I built a launcher 4.9.2 content-only project that reproduces the crash [here][1]. Tested it on an iPad 3 and it crashed as soon as it runs. Nothing useful is written to UE4’s , but the assertion failed message is printed on the device console:

Nov  9 17:05:21 iPad UE4Game[1373] <Warning>: Assertion failed: ClearValue.ColorBinding == EClearBinding::EColorBound [File:/Users/build/BuildFarm/build_++depot+UE4-Releases+4.9/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLCommands.cpp] [Line: 1842] 
	Texture: None does not have a color bound for fast clears

66177-scenecapturecrash.zip (159 KB)

I just pushed your project to an and an iPad 3. I pushed from the newest version of the engine, which is 4.10.0. I did not crash on either device. Could you please try with 4.10.0 and let me know how it goes for your iPad 3?

It doesn’t crash with 4.10.0. The SceneCapture2D also updates correctly (it was black in 4.9.2). I found the commit that fixed it: https://github.com/EpicGames/UnrealEngine/commit/a6cff3036eac29874bbbedde17e94f86c6a03535

It’s also a better solution than mine, since it changed ES2 to use the main color target and copy the result out to the FBO, which avoids potentially render target switching on legacy devices.