[UE4 OS X] Crashes in Metal

I am drawing custom things using RHI and shaders of my own. Everything works fine with DX11,OpenGL, GNM on Windows, Linux, OS X, PS4 and Xbox but it doesn’t work on OS X with Metal.
My setup is:

  • OS X - El Capitano
  • UE4 - 4.12.5
  • Xcode - 7.3.1

After further investigation I’ve discovered that FMetalContext::CurrentBoundShaderState is reset after calls to FRHICommandList::Clear.
I tried to explicitly set the shader state (via FRHICommandList::SetBoundShaderState)before every draw, but then I got a another crash inside bindSamplerToTexture which is a function inside inside the METAL Driver.
I also tried to rebind all the samplers and textures ( FGlobalShader::SetShaderSampler / SetShaderTexture), but the result was the same.
The log also shows the following unhelpful message: “Created a hitchy pipeline state for hash”

Any ideas what may be going wrong? Are there any Metal-specific invariants that I am breaking?
Finally, here’s the important part of the call stack that I get on the last crash:

#0	0x0000000157e2b4b6 in SamplerStage::bindSamplerToTexture(unsigned char, unsigned char, bool&, bool&) ()
#1	0x0000000157e2af97 in SamplerStage::writeSamplerState() ()
#2	0x0000000157e2323a in IGRenderStateSamplers::writeIf() ()
#3	0x0000000157e1eb1d in IGAccelRenderCommandEncoder::programPipeline(sPrimitiveData const&) ()
#4	0x0000000157e1f062 in IGAccelRenderCommandEncoder::drawIndexedPrimitives(unsigned long, unsigned int, unsigned long, MTLIGAccelBuffer*, unsigned int, unsigned int, unsigned int, unsigned int) ()
#5	0x0000000157e37eec in -[MTLIGAccelRenderCommandEncoder drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:] ()
#6	0x0000000159d1b9b9 in FMetalRHICommandContext::RHIDrawIndexedPrimitive(FRHIIndexBuffer*, unsigned int, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) at /Volumes/MacintoshHD2/ue-test/UnrealEngine/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalCommands.cpp:567
#7	0x0000000146bf8018 in FRHICommandList::DrawIndexedPrimitive(FRHIIndexBuffer*, unsigned int, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) at /Volumes/MacintoshHD2/ue-test/UnrealEngine/Engine/Source/Runtime/RHI/Public/RHICommandList.h:1598
#8	0x0000000146b49cc7 in FCohRenoirBackend::DrawIndexed(renoir::DrawIndexedCmd const*) at /Users/Coherent/Documents/Unreal Projects/MyProject3/Plugins/Runtime/Coherent/CoherentUIGTPlugin/Source/CoherentUIGTPlugin/Private/CohRenoirBackend.cpp:1432

sorry for insist but this issue is kind of urgent. Could you take a look it