1

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?

deve
  • 71
  • 5
  • I post the same question here. [https://discuss.cocos2d-x.org/t/utils-capturescreen-failed-assertion-on-ios-13-1-3/48140](https://discuss.cocos2d-x.org/t/utils-capturescreen-failed-assertion-on-ios-13-1-3/48140) Please see this. – deve Nov 08 '19 at 00:54

1 Answers1

0

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:

  1. Go to Edit Scheme
  2. Select the Run options in the sidebar
  3. Go to the Options tab
  4. Disable Metal API Validation

s3cur3
  • 2,749
  • 2
  • 27
  • 42