CustomMaterial crashes on iPad Pro 1st gen

When I launch any RealityKit app that uses a CustomMaterial with a surface shader on my iPad Pro 12.9" 1st gen (Model A1584, iPadOS 16.4.1, built with Xcode 14.3), it crashes with the following error message:

-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5446: failed assertion 'Draw Errors Validation Fragment Function (realitykit::fsSurfacePbr): the offset into the buffer clippingConstants that is bound at buffer index 6 must be multiple of 256 but was set to 128.

I can reproduce this with the sample code Altering RealityKit Rendering with Shader Functions as well as with an AR app I'm currently developing. Feedback FB12150033 already submitted to Apple.

Replacing all occurrences of CustomMaterial with a SimpleMaterial resolves the crash.

Can anyone confirm this? Any ideas for a workaround that lets me keep the shaders? I wouldn't want my app to crash on users of this iPad Pro, but surface shaders are essential in my app.

Answered by Graphics and Games Engineer in 752017022

Hi, thanks for the feedback. This is a crash in the Metal validation layer, which you can disable as a workaround in the project settings.

Accepted Answer

Hi, thanks for the feedback. This is a crash in the Metal validation layer, which you can disable as a workaround in the project settings.

Thanks a lot for the quick reply! Disabling Metal API Validation under Edit Scheme / Diagnostics did the trick.

Now I understand that this crash only occurs if I run the app via Xcode. When I launch it from the home screen, it doesn't crash, so this won't affect users after all :)

CustomMaterial crashes on iPad Pro 1st gen
 
 
Q