UE-48404 Assert Failed in FDefaultMaterialInstance::GetMaterial() UE 4.17

Hello, I am running version 4.17 and am encountering the problem described in the link below when attempting to run my game in iOS or the Mobile Preview ES2 in the editor.

Assertion failed:
!Material->IsDefaultMaterial()
[Engine\Source\Runtime\Engine\Private\Materials\Material.cpp]
[Line: 248]

// If we are the default material, must not try to fall back to the
default material in an error state as
that will be infinite recursion

The above link states that it was “Resolved - Mar 23, 2018” but doesn’t state which revision the fix was made in. How can I get this fix into my source code without upgrading to UE 4.18 / UE 4.19 ?

I tried debugging and it seems that MaterialResource->GetRenderingThreadShaderMap() is returning a null value. Is there any reason why the default material (Engine/EngineMaterials/WorldGridMaterial) would fail here?

My stack trace:

UE4Editor-Engine.dll!FDefaultMaterialInstance::GetMaterial(ERHIFeatureLevel::Type InFeatureLevel) Line 248	C++
UE4Editor-Renderer.dll!FRelevancePacket::MarkRelevant() Line 1991	C++
UE4Editor-Renderer.dll!ParallelFor(int Num, TFunctionRef<void __cdecl(int)> Body, bool bForceSingleThread) Line 179	C++
UE4Editor-Renderer.dll!ComputeAndMarkRelevanceForViewParallel(FRHICommandListImmediate & RHICmdList, const FScene * Scene, FViewInfo & View, unsigned char ViewBit, TArray<unsigned char,SceneRenderingAllocator> & OutHasDynamicMeshElementsMasks, TArray<unsigned char,SceneRenderingAllocator> & OutHasDynamicEditorMeshElementsMasks) Line 2154	C++
UE4Editor-Renderer.dll!FSceneRenderer::ComputeViewVisibility(FRHICommandListImmediate & RHICmdList) Line 2967	C++
UE4Editor-Renderer.dll!FMobileSceneRenderer::InitViews(FRHICommandListImmediate & RHICmdList) Line 79	C++
UE4Editor-Renderer.dll!FMobileSceneRenderer::Render(FRHICommandListImmediate & RHICmdList) Line 140	C++
UE4Editor-Renderer.dll!RenderViewFamily_RenderThread(FRHICommandListImmediate & RHICmdList, FSceneRenderer * SceneRenderer) Line 2058	C++
UE4Editor-Renderer.dll!TGraphTask<`FRendererModule::BeginRenderingViewFamily'::`46'::EURCMacro_FDrawSceneCommand>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 789	C++
UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 661	C++
UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 569	C++
UE4Editor-RenderCore.dll!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 329	C++
UE4Editor-RenderCore.dll!FRenderingThread::Run() Line 481	C++
UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 76	C++
UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 25	C++

Found a line of code that was calling GetMaterial(ERHIFeatureLevel::SM5) and since feature level SM5 is not available in mobile, it was causing the crash. Fixed now.