Open dqkona opened 4 years ago
How can i reproduce the crash?
It crashes on random places, while the Xcode debugger is attached to the app. Disabling the debugger solves the issues, so I'm not sure if is something from Apple's Metal code or your integration with Metal or both.
Try add a ClippingNode which running stencil animation and use the same image as Sprite to cover it on top, run and wait several minutes, it should be able to reproduce this crash.
Have you solved the problem
I also have this issue.
I also have this issue.Have you solved the problem?
Try add a ClippingNode which running stencil animation and use the same image as Sprite to cover it on top, run and wait several minutes, it should be able to reproduce this crash.
Can you provide the demo?
I also have this issue.Have you solved the problem?
Any available demo to reproduce the crash?
I have the same issue.
i have same issue too
I can avoid this problem in my game. Edit Scheme-->Run-->Options-->Metal API Validation:Disabled.
@losttoken I did that as well. The result was it crashed again, but it took more time in order for crash to happen.
Try add a ClippingNode which running stencil animation and use the same image as Sprite to cover it on top, run and wait several minutes, it should be able to reproduce this crash.
Can you provide the demo?
ClippingNode *clipperNode = ClippingNode::create();
clipperNode->setAlphaThreshold(1);
addChild(clipperNode, LAYER_OBJ);
Sprite *contentImg = Sprite::create("image.png");
contentImg->setPosition(Point(SCREEN_CENTER.x, SCREEN_CENTER.y));
clipperNode->addChild(contentImg);
Sprite *holesImg = Sprite::createWithSpriteFrame(contentImg->getSpriteFrame());
holesImg->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT);
holesImg->setPosition(contentImg->getPosition()-Point(holesImg->getContentSize().width/2,0));
Node* holesStencil = Node::create();
holesStencil->addChild(holesImg, -1);
clipperNode->setStencil(holesStencil);
holesStencil->runAction(RepeatForever::create(Sequence::create(ScaleTo::create(0, 0, 1),
ScaleTo::create(1, 1),
DelayTime::create(1.5),
NULL)));
Sprite* coverImg = Sprite::create("image.png");
coverImg->setPosition(Point(SCREEN_CENTER.x, SCREEN_CENTER.y));
addChild(coverImg);
Something similar can also reproduce this.
After a deep look, I found the problem.
DepthStencilStateMTL::~DepthStencilStateMTL() { _mtlDepthStencilState = nil; }
With this change, will not crash when Metal API validation turned on, can be verified by Test 24 Raw Stencil Tests.
https://stackoverflow.com/questions/29546193/the-concept-of-nil-in-c/29546646
id<MTLDepthStencilState> _mtlDepthStencilState = nil;
// versus..
_mtlDepthStencilState = static_cast<DepthStencilStateMTL*>(depthStencilState)->getMTLDepthStencilState()
looks tricky.
Getting EXC_BAD_ACCESS, when trying to access _mtlRenderEncoder on Director::mainLoop() flow