sceneview-android icon indicating copy to clipboard operation
sceneview-android copied to clipboard

Crash on closing SceneView with child node

Open Jessewb786 opened this issue 2 years ago • 1 comments

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.

Jessewb786 avatar Apr 01 '24 15:04 Jessewb786

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

ThomasGorisse avatar May 29 '24 17:05 ThomasGorisse

@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.

NikitaGvozdilko avatar May 31 '24 15:05 NikitaGvozdilko

This needs to be reopened, because even on version v2.2.1, it's still present:

2024-06-12 17:00:10.290  1622-1622  Filament                io.powered.fusion.factory.client     E  in terminateAndDestroy:941
                                                                                                    reason: Object <no-rtti> at 0xb400007cd5435f40 doesn't exist (double free?)
2024-06-12 17:00:10.290  1622-1622  Filament                io.powered.fusion.factory.client     E  
2024-06-12 17:00:10.346  1622-1622  Sceneview               io.powered.fusion.factory.client     D  Engine destroyed
2024-06-12 17:00:10.355  1622-1622  libc                    io.powered.fusion.factory.client     A  Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2a8 in tid 1622 (.factory.client), pid 1622 (.factory.client)
2024-06-12 17:00:11.456  1926-1926  DEBUG                   crash_dump64                         A  Cmdline: io.powered.fusion.factory.client
2024-06-12 17:00:11.456  1926-1926  DEBUG                   crash_dump64                         A  pid: 1622, tid: 1622, name: .factory.client  >>> io.powered.fusion.factory.client <<<
2024-06-12 17:00:11.456  1926-1926  DEBUG                   crash_dump64                         A        #00 pc 00000000002710b0  /data/app/~~VrReJWOzVoPhO5ig3bwt9g==/io.powered.fusion.factory.client-bup8UNPZGKAxkWT6OrqD1w==/base.apk!libgltfio-jni.so (BuildId: 7cd5c38ac6c996099d5e6e13af7584be5f5147fc)

I'm still compelled to keep my workaround present, because it's the only way it works for me.

Jessewb786 avatar Jun 12 '24 15:06 Jessewb786

Definitely still an issue that's crashing for me in v2.2.1

psh avatar Oct 01 '24 18:10 psh