Skip to content

Native crash introduced in v2.3.0 related to ImageNode #630

@yakovliev-hover

Description

@yakovliev-hover

Known Facts

  • Crash is device-dependent. I managed to reproduce it on Samsung S20 SM-G981U1 and can not reproduce it on my other two devices
  • Crash appeared in v2.3.0 and not exists in previous v2.2.1 on this Samsung S20 SM-G981U1
  • It is related to Filament. Also, I experimented with upgrading to the latest filament (1.63.0) but this did not help.
  • Crash is floating on Samsung S20, which means, different time is needed to reproduce it. Sometimes quickly, sometimes several minutes. But in most cases, it is quite easy to reproduce it on this device.

What I know based on filament-related investigation.

  • Some panic triggers this in libfilament-jni.so
  • Preconditions are “Invalid texture still bound to MaterialInstance: 'Transparent Textured'”
  • In arsceneview, ‘Transparent Textured'’ mentioned in image_texture.filamat and it is related to val imageTextureMaterial in MaterialLoader and used in ImageNode.
  • I see the place in filament repo, where this precondition was added. Btw, when looking to time in git blame, it was added somewhere between 1.52 and 1.56 releases. Looks like this code block checks list of textures in mTextureParameters and if some of them do not pass check engine.isValid(p.texture), this precondition can be thrown.

Sample project, MRE

This is a link to MRE (minimal reproducible example) where this can be reproduced, but I want to highlight that the problem is device-dependent and for me reproduced on Samsung S20 SM-G981U1 but I believe, subset of such devices where this can be reproduced is bigger

In addition to the sample above, adding here a snippet how ImageNode is processed to reproduce this issue

    /**
     * This just emulates how ImageNode might be used in a real application.
     */
    private fun emulateAddingAndRemovingImageNode() {
        lifecycleScope.launch {
            delay(2000) // wait until everything is initialized
            val bitmap = readBitmapFromAssets()

            while (true) {
                bitmap?.let {
                    updateGroundPlaneNode(it)
                }

                /**
                 * Delay can be increased or decreased, but floating native crash still happens
                 * on v2.3.0 on specific devices (reproduced on Samsung S20 SM-G981U1).
                 * The same issue is not reproducible on v2.2.1 on the same device.
                 * The same issue is not reproducible on v2.3.0 on other devices.
                 */
                delay(100)
            }
        }
    }

    private fun updateGroundPlaneNode(
        bitmap: Bitmap
    ) {
        lastGroundPlaneNode?.let { node ->
            sceneView.removeChildNode(node)
            node.destroy()
        }

        val xForNode = 1.0f
        val yForNode = -1.0f
        val zForNode = -2.0f

        lastGroundPlaneNode = ImageNode(
            materialLoader = sceneView.materialLoader,
            bitmap = bitmap,
            size = Size(5f, 5f),
        ).apply {
            transform(
                position = Position(
                    xForNode,
                    yForNode,
                    zForNode
                ),
            )
            rotation = Direction(x = -90f, y = 0f, z = 0f)
        }

        lastGroundPlaneNode?.let { sceneView.addChildNode(it) }
    }

How logs looking

Image

and same by text

2025-08-12 15:34:28.307 22652-22652 Filament                com.example.mre                      E  Precondition
                                                                                                    in commit:200
                                                                                                    reason: Invalid texture still bound to MaterialInstance: 'Transparent Textured'
2025-08-12 15:34:28.307 22652-22652 Filament                com.example.mre                      E  
2025-08-12 15:34:28.308 22652-22652 libc                    com.example.mre                      A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 22652 (com.example.mre), pid 22652 (com.example.mre)
2025-08-12 15:34:28.664 22912-22912 DEBUG                   pid-22912                            A  Cmdline: com.example.mre
2025-08-12 15:34:28.664 22912-22912 DEBUG                   pid-22912                            A  pid: 22652, tid: 22652, name: com.example.mre  >>> com.example.mre <<<
2025-08-12 15:34:28.664 22912-22912 DEBUG                   pid-22912                            A        #01 pc 00000000001e8ff0  /data/app/~~PEovf-aZmiXJvsmSh0CwIg==/com.example.mre-4DaxN6FdNeeALKPSnE2UqQ==/base.apk!libfilament-jni.so (utils::TPanic<utils::PreconditionPanic>::panic(char const*, char const*, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >)+176) (BuildId: e4808a0d8351fa3dd1fef38b5ae16b9358b67021)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions