I'm using cocos2d-x 3.17.2 and running my App on iPad mini 5th iOS 13.1.3.
When I call utils::captureScreen, it causes assertion failure.
_validateGetBytes:29: failed assertion `CPU access for textures with MTLResourceStorageModePrivate storage mode is disallowed.'
It seems like a MTLResourceStorageMode related problem.
But I can't find out how to fix this.
I run the same code on iOS 11.4.1 iPod touch 6th, and on iOS 12.4.3 iPad mini 2nd, but these 2 devices don't cause this problem, they run perfect.
Here is my code.
string path = FileUtils::getInstance()->getWritablePath().append("screenshot.jpg");
Label *path_lbl = Label::createWithSystemFont(path, "", 20.0);
const char* filename = path_lbl->getString().c_str();
utils::captureScreen([&](bool succeed,const std::string &fileName){}, filename);
and assertion failed on the line: ccUtils.cpp: Line 105
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get());
Does anyone know how to fix this problem?
Something about the underlying Metal implementation of
glReadPixels()is violating the Metal rules for memory access as of iOS 13.1 (and it's not fixed as of 13.3.1).The good news is, this is a debugging check only. When not attached to the Xcode debugger, it will "just work." To get Xcode to let it slide, you can: