Engine crashes on load or when changing viewport to orthographic

Problem:

The engine silently crashes on level load or when changing the viewport to an orthographic view.

Cause:

The problem is that the orthographic viewport cameras are not properly initialized sometimes. This causes
FEditorCommonDrawHelper::DrawGridSection to overflow when because:

const float Zoom = (1.0f / View->ViewMatrices.ProjMatrix.M[0][0]) * 2.0f / SizeX;

gets set to an extremely large value which causes IncScale to overflow to zero:

float IncValue = FMath::LogX(Exponent, Dist / (float)(SizeX / Tweak));

int32 IncScale = 1;

for(float x = 0; x < IncValue; ++x)
{
	IncScale *= Exponent;
}

Which causes an unhandled divide by zero exception:

const int32 FirstLineClamped = FMath::Max<int32>(FirstLine - 1,-HALF_WORLD_MAX/ViewportGridY) / IncScale;
const int32 LastLineClamped = FMath::Min<int32>(LastLine + 1, +HALF_WORLD_MAX/ViewportGridY) / IncScale;

Workarounds:

  • Open an empty level
  • Disable grid drawing
  • Open the problematic level, select an object in your world, hit F to cause the viewport to center around the object
  • Renable grid drawing

Solution

Not sure the exact context of what causes the ortho views to be uninitialized. We have several very large levels in a single map that are streamed in. Didn’t have time to do in-depth call stack trace but I’m sure someone from Epic who knows this part of the code can fix it quickly.

1 Like

Hello Ikrima. Thank you for your report of the crash that you are experiencing. I was able to reproduce the crash in the currently released versions of the Editor. However, I was unable to get the crash to occur in the latest internal version that I have available. It appears that this issue has already been investigated and corrected, and we do not expect it to continue to occur in future release versions.

Have a great day!

In 4.1.0 engine version the crash allows me to send a bug report using the UE reporter UI. Just updated the engine to 4.1.1 and the crash persists, but doesn’t open the bug report UI.

Hi ojrask,

Please make another answerhub post as your bug does not seem to be the same as the one posted by Ikrima Elhassan. In your new post, please include the nature of your bug/crash, any log files (found in the file /projectname/saved/logs), and your dxdiag. Thank you!