Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
iOS crash: setVertextBytes() failed assertion — Gideros Forum

iOS crash: setVertextBytes() failed assertion

PaulHPaulH Member
edited March 24 in General questions
I've just released new code on Android and I'm having new issues trying to get it running on iOS. The metal shader is quitting with an error:

setVertexBytes:length:attributeStride:atIndex:]:1719: failed assertion `Set Vertex Bytes Validation length(4416) must be <= 4096.'

I thought at first this might be an issue with the 3D scene getting excessively complete, as this is my first release using instancing, but at the time this happens the app is only trying to render some non-instanced meshes. I'm still digging into this but so far I don't have a clue what to do about this.

This is with Gideros 2024.3 and the latest Xcode.

Comments

  • PaulHPaulH Member
    I've moved back to Gideros 2023.11, and was still having the crash until I had it leave the animated vise model out of the scene. Then it doesn't crash. So perhaps that model has too many vertexes in a single object? I can simplify it or divided it, but is there really a limit of 4k vertexes per object?

    I'm also seeing a lot of graphical issues that look like RenderTarget:clear() isn't working, but maybe that's just a 2023.11 issue.
  • PaulHPaulH Member
    I'm seeing the same missing textures in 2024.03, textures that are created on the fly with a series of RenderTargets and Shapes. There's definitely a lot of cases where either rt:clear() or rt:draw() are failing when running on the iPad. It's fine in the iOS simulator and Gideros Player, so I'm assuming it's an issue specific to the metal shaders. I'll keep digging.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • PaulHPaulH Member
    The mesh that triggers the crash has only 710 vertexes, but I tried with a version with 610 and still got the same text in Xcode with the crsah, that 'SetVertex Bytes Validation length(4416) must be < 4096", so whatever is going on isn't just a matter of the count of vertexes.
  • PaulHPaulH Member
    I've got my app to run on an iOS device, but not with the current or recent 3d libraries and lua shaders. The only way I've had any project run on iOS using animated meshes loaded with buildGdx has been to remove the lua shader library, and swap out the 3D base library for the one from November 2021. Then it works fine. Well, not entirely. There are issues, like the near rendering distance is different some some geometry gets clipped, but it doesn't crash.

    Has anybody used 3D animation via buildGdx and had it work on iOS with the current libraries?

    Here's a simple project that just displays a fish hook in 3D, made from an animated mesh and shaped by the code: http://www.pishtech.com/beta/hook.zip For me this works everywhere but on iOS where it fails with the failed assertion in SetVertexBytes mentioned above.


  • MoKaLuxMoKaLux Member
    edited March 24
    sorry PaulH I never had any apple devices and never targeted one so cannot help here :(

    Likes: PaulH

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    PaulH said:

    The mesh that triggers the crash has only 710 vertexes, but I tried with a version with 610 and still got the same text in Xcode with the crsah, that 'SetVertex Bytes Validation length(4416) must be < 4096", so whatever is going on isn't just a matter of the count of vertexes.

    There are only two calls to setVertexBytes in Gideros: one is to set the uniforms/constants, and I doubt it could go beyond 4096 bytes with current Gideros shaders.
    The other is more likely: it is used for vertex attributes (vertices, texture coordinates, normals, etc), but only if their sizes are below 4096.
    Except that the way is code is written, it would also be invoked if Metal couldn't a specific buffer when size is greater than 4096, probably due to resource starvation.
    In Metal, there seem to be a limit on the number of buffer you can allocate (maybe 64k, I don't know). And you may have up to 4 buffers for a single mesh (including indices).
    If that's what happens, I'll need to rework the way buffers are used in Metal, in a way similar to what I've done for OpenGL.
    +1 -1 (+1 / -0 )Share on Facebook
  • PaulHPaulH Member
    Thanks for looking into this. The project I linked above that reproduces it is pretty light on resources. The only mesh has under 400 vertices.
  • hgy29hgy29 Maintainer
    Sorry, I overlooked your example.
    I don't manage to download it though, I get à 404 error.
  • PaulHPaulH Member
    Sorry - I uploaded it to the wrong folder. It's at: https://www.pishtech.com/hook.zip

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    @PaulH, I checked and yes I was wrong, animated 3D meshes actually do exceed the 4096 bytes limit for constants, because of the provision for 64 bones matrices (each taking 64 bytes). Maybe 64 bones is too much anyhow, I think it could be lowered to 48.

    It just needs a change in line 49 of 3DLighting.lua

    Likes: PaulH

    +1 -1 (+1 / -0 )Share on Facebook
  • PaulHPaulH Member
    Would that then be the limit for the number of bones in a mesh? One of my current games uses a model with 69 bones at load time, a human figure, to draw to RenderTargets to make sprites to use during game play. It would be possible to split into separate meshes - upper and lower body, if that
  • MoKaLuxMoKaLux Member
    I believe I also use 60+ bones for 3d human characters (mixamo rig), so 48 would be too low?

    Likes: PaulH

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    So you both think I should be a bit less lazy and properly handle the case in Metal driver in order to have 64 or even a lot more bones ? All right, I think it is not too difficult after all :)

    Likes: keszegh, MoKaLux, PaulH

    +1 -1 (+3 / -0 )Share on Facebook
  • PaulHPaulH Member
    Thanks so much!

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.