Hello
While testing several models for our app, we encountered the following error during the initialization of model:
-[MTLDebugDevice newBufferWithLength:options:]:642: failed assertion `Buffer Validation
Cannot create buffer of zero length.`
Coming from the lines:
(CubismComandBuffer_Metal)
Line 89
_vertices = [device newBufferWithLength:_vbStride * count
options:MTLResourceStorageModeShared];
(CubismRenderer_Metal)
Line 1310
const csmInt32 drawableVertexCount = model->GetDrawableVertexCount(i);
Line 1317
_drawableDrawCommandBuffer[i]->CreateVertexBuffer(device, vertexSize, drawableVertexCount);
We tried the models in frameworks CubismSdkForNative-4.r.7 and CubismSdkForNative-5.r.1-beta.3 both in the demo app and in our app and both resulted in the mentioned error. (Simulator and real device)
The target model can be downloaded via
https://ko-fi.com/s/867102f774. It's free.
This issue is caused by value 0 from "model->GetDrawableVertexCount(i)" some value of an array on a certain index has value 0. I was wondering if it's normal that the array contains zeros sparsely. We found the workaround to return 1 instead of 0 to resolve it. That's working now, but I am afraid that it's the right approach.
As mentioned again to be clear, it occurs on the demo app for native provided by Live2D.
Thank you in advance.