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 on closing SceneView with child node #452

Closed
Jessewb786 opened this issue Apr 1, 2024 · 2 comments
Closed

Crash on closing SceneView with child node #452

Jessewb786 opened this issue Apr 1, 2024 · 2 comments

Comments

@Jessewb786
Copy link

Jessewb786 commented Apr 1, 2024

I have a view that shows a model:

val engine = rememberEngine()
val modelLoader = rememberModelLoader(engine)
val materialLoader = rememberMaterialLoader(engine)
Scene(
    modifier = Modifier
        .fillMaxSize(),
    engine = engine,
    modelLoader = modelLoader,
    view = rememberView(engine) {
        SceneView.createView(engine).apply {
            setShadowingEnabled(true)
            ambientOcclusionOptions.enabled = true
        }
    },
    childNodes = rememberNodes {
        add(
            element = ModelNode(
                modelInstance = modelLoader.createModelInstance(R.raw.part),
                scaleToUnits = 0.5f,
                centerOrigin = Position(x = 0.0f, y = -0.5f, z = 0.0f)
            ).apply {
                rotation = Rotation(y = -45f)
                renderableNodes.forEach { node ->
                    node.setMaterialInstances(
                        materialInstance = materialLoader.createColorInstance(Color.Gray)
                    )
                }
            }
        )
    },
    environment = rememberEnvironment(engine) {
        SceneView.createEnvironment(
            engine = engine,
            skybox = Skybox.Builder()
                .color(colorOf(rgb = 0.2f, a = 1.0f).toFloatArray())
                .build(engine)
        )
    }
)

When leaving, by default, this will crash with (Note that the crash does not happen is there is no childNode):

2024-04-01 16:47:13.097 32172-32172 Filament                E  in terminateAndDestroy:929
                                                               reason: Object <no-rtti> at 0xb4000077109fb500 doesn't exist (double free?)
2024-04-01 16:47:13.097 32172-32172 Filament                E  
2024-04-01 16:47:13.108 32172-32172 Sceneview               D  Engine destroyed

As a workaround, I override the original Scene method to do the following which solves the crash:

onRelease = { sceneView ->
    sceneView.childNodes = emptyList()
    sceneView.destroy()
}

It appears that there could be a second destroy somewhere that is leading to this crash.

@ThomasGorisse
Copy link
Contributor

Reopen if it's still the case in v2.2.0

@NikitaGvozdilko
Copy link

@ThomasGorisse It still exists in v2.2.0
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

It is fixed for first 2-3 navigations, but then it crashed again.

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

3 participants