Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash When Rendering Specific GLB Models Due to Missing "sheenColorIndex" #593

Open
Mehrdadjdev opened this issue Jan 24, 2025 · 2 comments

Comments

@Mehrdadjdev
Copy link

I'm encountering a crash while rendering certain GLB models using SceneView. While most models work perfectly, some cause the app to crash with the following error:

Panic  
    in getFieldInfo:170  
    reason: uniform named "sheenColorIndex" not found  
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15095 (.example), pid 15095 (.example)  
  Cmdline: com.example.example  
pid: 15095, tid: 15095, name: .example  >>> com.example.example <<<  
        #01 pc 00000000001dc99c  /data/app/~~MwG87CnQ4Ab2bBh-Qo23-A==/-LWYkR3orsy1RGSTfSynaZw==/base.apk!libfilament-jni.so (utils::TPanic<utils::PreconditionPanic>::panic(char const, char const, int, char const*, ...)+204) (BuildId: c1ee70bcc213bdfcce2421b7860127c85b755d6d)  

Sample code:

@Composable
fun model3DViewer() {

    val engine = rememberEngine()
    val modelLoader = rememberModelLoader(engine)
    val environmentLoader = rememberEnvironmentLoader(engine)

    val centerNode = rememberNode(engine)

    val cameraNode = rememberCameraNode(engine) {
        position = Position(x = 2f, y = 3f, z = 1.0f)
        lookAt(centerNode)
        centerNode.addChildNode(this)
    }

    // State to control camera rotation
    val isCameraRotating = remember { mutableStateOf(true) }

    val cameraTransition = rememberInfiniteTransition(label = "CameraTransition")
    val cameraRotation by cameraTransition.animateRotation(
        initialValue = Rotation(y = 0.0f),
        targetValue = Rotation(y = 360.0f),
        animationSpec = infiniteRepeatable(
            animation = tween(durationMillis = 7.seconds.toInt(MILLISECONDS))
        )
    )

    val environment = environmentLoader.createHDREnvironment(
        assetFileLocation = "environments/farm_field_puresky_1k.hdr"
    )!!

    val indirectLight = environment.indirectLight

    val modelNode = ModelNode(
        modelInstance = modelLoader.createModelInstance(
            assetFileLocation = "models/model_Sample.glb"
        ),
        scaleToUnits = 2f
    )

    modelNode.scale(2)

    Scene(
        modifier = Modifier.fillMaxSize(),
        engine = engine,
        modelLoader = modelLoader,
        cameraNode = cameraNode,
        cameraManipulator = rememberCameraManipulator(
            orbitHomePosition = cameraNode.worldPosition,
            targetPosition = centerNode.worldPosition
        ),
        childNodes = listOf(centerNode,
            rememberNode {
                modelNode
            }),
        environment = Environment(
            indirectLight = indirectLight,
            skybox = null,

            ),
        onFrame = {
            if (isCameraRotating.value) {
                centerNode.rotation = cameraRotation
                cameraNode.lookAt(centerNode)
            }
        },
        onGestureListener = rememberOnGestureListener(
            onDown = { _, _ ->
                // Stop camera rotation on any gesture
                isCameraRotating.value = false
            },
        ),
        isOpaque = false,
    )

}

Observations:
The issue appears to stem from the sheenColorIndex uniform, which is not found in some GLB models.
Filament crashes when trying to process this property.
Unfortunately, I cannot re-export the problematic GLB models in Blender, as they are shared with another app (based on Sceneform: https://github.com/SceneView/sceneform-android) that renders them without issues.

Questions:

  • Is there a way to ignore unsupported properties like sheenColorIndex in SceneView without crashing the app?
  • Can a workaround be applied to handle this situation without modifying the GLB models themselves?

I would greatly appreciate any advice or guidance on how to resolve this issue. Let me know if you need additional details or if there are specific steps I should follow to debug further.

Thanks in advance!

@execute008
Copy link

Matter the fact that it is a filament error, maybe bumping up the filament version, overwriting the version of SceneView helps.

Last update of SceneView was in June last year and ArCore and Filament had some updates since then, so maybe you are lucky.

@Mehrdadjdev
Copy link
Author

@execute008 Thank you for your suggestion. It's worth noting that support for sheenColor in Filament was added on December 11, 2020, as detailed in this pull request.
Given that my model renders correctly with Sceneform-Android version 1.23.0, which utilizes Filament version 1.15.1, it seems the issue may lie within SceneView's implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants