Babylon React Native custom ShaderMaterial error on iOS

@bghgary We have a custom ShaderMaterial in a Babylon React Native project which works fine on Android but fails with the following error on iOS.

-[MTLVertexDescriptorInternal newSerializedDescriptor], line 726: error 'Serialized Descriptor Creation
Attribute at index 1 references a buffer at index 1 that has no stride.
'
-[MTLVertexDescriptorInternal newSerializedDescriptor]:726: failed assertion `Serialized Descriptor Creation
Attribute at index 1 references a buffer at index 1 that has no stride.
'
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/usr/lib/libMTLCapture.dylib
-[MTLVertexDescriptorInternal newSerializedDescriptor]:726: failed assertion `Serialized Descriptor Creation
Attribute at index 1 references a buffer at index 1 that has no stride.

A playground version of the shader is available here: https://www.babylonjs-playground.com/#U2C1Q6#44

Native Android build works fine and the playground runs as expected in Chrome on both Mac OS and iOS, so it’s just native iOS build that results in the error.

Is there something else I need to do for iOS or could this be a bug?

image

Line 96

pcs.mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normal);

What’s happening if you replace it with ?

pcs.mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normal, true, 3);

The playground creates the mesh in that way but our Babylon Native code uses pcs.addSurfacePoints() as per Creating A Point Cloud System | Babylon.js Documentation

But the shader code is identical.

Seems like a bug to me. @Cedric Do you already know what is wrong? If not, let’s get an issue filed.

No idea

Thanks for looking into it @Cedric and @bghgary

@inteja

I just tried with latest master version of BabylonNative (not react) as this looks like a rendering issue not related to react and it works.

Can you also please try to run the PG on BabylonNative on your side?

What’s your iphone? What’s your Xcode version?

@Cedric can you please clarify? You want me to run the code in the master branch of Babylon Native, not Babylon React Native? I’m not even sure how to go about that as our project is a Babylon React Native project.

I’ll check on our xcode and iOS hardware and get back to you.

Sure! clone GitHub - BabylonJS/BabylonNative: Build cross-platform native applications with the power of the Babylon.js JavaScript framework, build for ios and modify experience.js with copy/paste of your PG.

I managed to get it working on an iPhone X

OK thanks @Cedric . It could take me a bit of time to get back to you as I have a few other things to complete first.

1 Like

@Cedric here’s the info you asked for:

Build Environment
Apple M1 Max
macOS Monterey 12.2.1
Xcode13.3

Deploy Target
iPad Pro (11-inch) (3rd generation)
iOS 15.4.1

I’ll get back to you when I’ve had a chance to try in Babylon Native directly.

2 Likes

Hi @inteja any update on the test?

1 Like

Hi @Cedric thanks for the follow-up. I’ve got some time in our upcoming sprint to create a simpler test case for this and the strange GLB load issue we’re having also.

1 Like

Hey @inteja , do you have an update on this shader issue? Could you test it with babylon native? do you have a repro script?

Hi @Cedric . Sorry I don’t have any new information that could help. I ended up refactoring and migrating my shaders from ShaderMaterial to material plugins and we haven’t seen this error since then. Likely it was something I was doing wrong but there definitely was a difference between the shaders working in Android but not iOS at that time. I’ve used ShaderMaterial again recently with no issues on either platform.

2 Likes