google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.59k stars 1.86k forks source link

Android `asyncCancelLoad` causing crash #7650

Open akshaytaru2007 opened 6 months ago

akshaytaru2007 commented 6 months ago

⚠️ Issues not using this template will be systematically closed.

Describe the bug I am getting the crash in Android which is pointing to resourceLoader asyncCancelLoad

To Reproduce Steps to reproduce the behavior: Code:

var asset: FilamentAsset? = null
        private set
private var resourceLoader: ResourceLoader

.
.
.

resourceLoader = ResourceLoader(engine, normalizeSkinningWeights)

fun loadModelEmbeddedGltf(buffer: Buffer) {

        destroyModel()
        asset = assetLoader.createAsset(buffer)
        asset?.let { asset ->

            this.resourceLoader.asyncBeginLoad(asset)
            this.animator = asset.instance.animator
            asset.releaseSourceData()
        }
    }

    fun destroyModel() {    
        resourceLoader.asyncCancelLoad()

        resourceLoader.evictResourceData()
        asset?.let { asset ->
            this.scene.removeEntities(asset.entities)
            assetLoader.destroyAsset(asset)
            this.asset = null
            this.animator = null
        }
    }

What I am trying to do: I have model say Cube. Use can tap on it to change color. User can select different color and everytime user taps the model gets rendered.

Steps:

  1. I load my model when user taps and it calls loadModelEmbeddedGltf()
  2. If user taps multiple times, I am getting above error.

I m not sure why this is happening, I m trying to understand what is going wrong. I am just fixing the issue that I am facing.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Logs

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone64_arm64/emu64a:14/UE1A.230829.036.A1/11228894:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2024-03-11 19:43:11.842770963+0530
Process uptime: 310s
Cmdline: com.myapp.develop
pid: 16161, tid: 17606, name: JNISurfaceTextu  >>> com.myapp.develop <<<
uid: 10191
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xb400006c8b6ca18c
    x0  b400006ea2329210  x1  0000000002394a18  x2  000000000000000a  x3  0000000000000001
    x4  00000000000084fe  x5  0000000000002600  x6  00000000000026fe  x7  0000000000002801
    x8  0000006c52829d00  x9  000000002394a180  x10 0000000000000312  x11 0000000000000000
    x12 0000000000000000  x13 0000000000000000  x14 0000006c52829d50  x15 0000006c52829d60
    x16 b400006ea232a808  x17 00000000001fffbe  x18 0000006c4ea42000  x19 aaaaaaaaaaaaaaab
    x20 b400006ea2329210  x21 b400006c67d80170  x22 000000000000000c  x23 0000006c52829d00
    x24 b400006da225f500  x25 0000000000000008  x26 0000000000000000  x27 0000000000000000
    x28 0000000000000001  x29 b400006c8b6ca180
    lr  0000006c8e7554ac  sp  0000006cfdcfb950  pc  0000006c8e75d670  pst 0000000000001000
1 total frames
backtrace:
      #00 pc 000000000015d670  /data/app/~~91yPX3rb5z0ROeuEN0ZHWA==/com.myapp.develop-hHxUCtAf_xZszGSo3fbORQ==/lib/arm64/libfilament-jni.so (BuildId: bbfa6b6da6f7e3152f06532e8d0ec8f193401536)

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context I am trying to understand the root cause of the problem.

akshaytaru2007 commented 5 months ago

@poweifeng Any update on this?

@pixelflinger This happens when user taps very quickly. I can prevent that if I can get a callback from which let us know that view being rendered and view is rendered. So, we can block UI and release once view is rendered.

I didn't find any such callback in documentation.

Thanks

poweifeng commented 5 months ago

Sorry for the delay, I'll take a look in the next few days.

akshaytaru2007 commented 5 months ago

@poweifeng Did you get time to look into this? Please take a look, we are having crash in production.

poweifeng commented 5 months ago

I did identify a crash, though I don't know if it's related to the crash here. But I'll update soon.

poweifeng commented 5 months ago

I'm unable to reproduce your crash. Can you share the following:

Thanks!

akshaytaru2007 commented 4 months ago

@poweifeng I am trying to reproduce the bug in a different project so I can share the link. Meanwhile, what do you think is the crash? I would appreciate your insights. Thanks