Multiple MetalKit View crashes

I am trying to use multiple metalkit views, but they crash at this point in the rendering.


MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor;

id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];

I have verified that the view and commandBuffer are created. I am using the prebuilt code from Xcode using the game application with Metal. I have not modified the code. I simply created a second view and second view controller and linked the two.


Any ideas of why this is happening?

What is the crash message?

The crash is below. Just to reiterate I have not modified the code in anyway. All I did was take Apple's autogenerated Metal code for their game application. I added another view in the nib and linked it to a new view controller. If I remove the second view it works fine.



AMDMTLBronzeDriver`amdMtlBronzeCmdBufAddInternalResource(BronzeCmdBufInfoRec*, MTLIOAccelResource*) + 16, name = 'CVDisplayLink', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)

frame #0: 0x000000010271c8f5 AMDMTLBronzeDriver`amdMtlBronzeCmdBufAddInternalResource(BronzeCmdBufInfoRec*, MTLIOAccelResource*) + 16

frame #1: 0x00000001026dc555 AMDMTLBronzeDriver`BltMgrBase::AddHandle(ContextStatus*, void*, unsigned int, _VCOP_RESOURCE_TYPE, unsigned int, unsigned int, _UBM_ADDHANDLE_INPUT_FLAGS) + 101

frame #2: 0x00000001026fd1f5 AMDMTLBronzeDriver`SiBltDrawRegs::SetupAndWriteDepth(BltInfo const*) + 1013

frame #3: 0x0000000102702bef AMDMTLBronzeDriver`SiBltMgr::SetupAndWriteDrawBltSurfInfo(BltInfo*) + 63

frame #4: 0x0000000102705788 AMDMTLBronzeDriver`SiBltMgr::Execute3dDrawBlt(BltInfo*) + 504

frame #5: 0x00000001026ff0c3 AMDMTLBronzeDriver`SiBltMgr::Execute3dBlt(BltInfo*) + 243

frame #6: 0x00000001026de5d2 AMDMTLBronzeDriver`BltMgr::Clear(BltDevice*, _UBM_CLEARINFO*) + 2386

frame #7: 0x000000010271ff3b AMDMTLBronzeDriver`amdMtlBronzeDoDepthClear(BronzeDeviceMembersRec*, BronzeCmdBufInfoRec*, BronzeMtlTexture*, unsigned int, unsigned int, unsigned int, double) + 328

frame #8: 0x000000010272bf26 AMDMTLBronzeDriver`___lldb_unnamed_function334$$AMDMTLBronzeDriver + 1527

frame #9: 0x00000001027240a4 AMDMTLBronzeDriver`___lldb_unnamed_function188$$AMDMTLBronzeDriver + 218

frame #10: 0x00000001001213d7 MetalTools`-[MTLDebugCommandBuffer renderCommandEncoderWithDescriptor:] + 388

* frame #11: 0x0000000100001b77 TestMultiView`-[GameViewController _render](self=0x0000000100308d10, _cmd=0x0000000100004164) + 215 at GameViewController.m:147

frame #12: 0x0000000100003803 TestMultiView`-[GameViewController drawInView:](self=0x0000000100308d10, _cmd=0x00007fff9956e481, view=0x0000000100307970) + 67 at GameViewController.m:218

frame #13: 0x000000010008b59e MetalKit`-[MTKView draw] + 440

frame #14: 0x0000000100089fea MetalKit`DisplayLinkCallback + 20

frame #15: 0x00007fff99e4dc06 CoreVideo`CVDisplayLink::performIO(CVTimeStamp*) + 258

frame #16: 0x00007fff99e4d791 CoreVideo`CVDisplayLink::runIOThread() + 627

frame #17: 0x00007fff99e4d1f5 CoreVideo`startIOThread(void*) + 147

frame #18: 0x00007fff981afcc3 libsystem_pthread.dylib`_pthread_body + 131

frame #19: 0x00007fff981afc40 libsystem_pthread.dylib`_pthread_start + 168

frame #20: 0x00007fff981acda5 libsystem_pthread.dylib`thread_start + 13

Hi teaglin,


Are you still running into this on recent seed builds? If so, can you file a radar and attach your project?


Thanks.

In all builds up until the most recent one, the MTKView could actually give you a null renderPassDescriptor (at which point you can just return from the delegate method without doing anything). The problem seems gone in 15A244d.

Does this issue still persist to the knowledge of Apple? Since adding a second MTKView to my application I get a consistent assertation (NVIDIA GeForce GT 650M, or Intel 4000, OS X 10.11.2):


when evaluating the property currentDrawable of an MTKView from within drawInMTKView(view: MTKView) (all loaded from a Storyboard) as before I get:


/Library/Caches/com.apple.xbs/Sources/Metal/Metal-55.2.8/ToolsLayers/Debug/MTLDebugDevice.mm:629: failed assertion `iosurface must not be nil.'


Both MTKViews are configured with paused = true and enableSetNeedsDisplay = true. Any idea what to do here?

Multiple MetalKit View crashes
 
 
Q