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: SurfaceTexture::detachFromContext (Android) #31

Closed
seth35us opened this issue Sep 13, 2021 · 3 comments
Closed

Crash: SurfaceTexture::detachFromContext (Android) #31

seth35us opened this issue Sep 13, 2021 · 3 comments

Comments

@seth35us
Copy link

seth35us commented Sep 13, 2021

I am getting a SurfaceTexture crash when using the BottomNavBar. The crash is not immediate, but happens after a little use.

Here is a possible fix: flutter/flutter#83090.

         ThreadManager.getUIHandler().postDelayed({
            surfaceTextureEntry?.let {
                it.release()
                surfaceTextureEntry = null
            }

        }, 2000)

Your code I found is in the BarcodeReader.kt:

        cameraSurfaceProvider = Preview.SurfaceProvider {
            val surfaceTexture = flutterTextureEntry.surfaceTexture()
            surfaceTexture.setDefaultBufferSize(it.resolution.width, it.resolution.height)
            it.provideSurface(Surface(surfaceTexture), cameraExecutor, Consumer {})
        }

crash:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x660
Cause: null pointer dereference

backtrace:
#00 pc 00000000000e41b8 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_lock) (BuildId: 5812256023147338b8a9538321d4c456)
#1 pc 000000000039d060 /system/lib64/libhwui.so (android::SurfaceTexture::detachFromContext()+64) (BuildId: 6e92c400e69e5edfa313569de08cd930)
#2 pc 000000000016a420 /system/lib64/libandroid_runtime.so (android::SurfaceTexture_detachFromGLContext(_JNIEnv*, _jobject*)+80) (BuildId: e5b25f8fb9f6bb45ccbeca8c07061dad)
#3 pc 000000000028dc6c /system/framework/arm64/boot-framework.oat (art_jni_trampoline+124) (BuildId: cb00916f88c36b463e3b56b54e52d4229c505963)
#4 pc 0000000000136334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)

@jhoogstraat
Copy link
Owner

Can you post a minimum working example showing this error? Otherwise, it's a bit tricky to debug.

I am unsure at what point exactly the FlutterTextureEntry has to be released when using a bottom nav bar, but I'll put it in dispose as this is a sure point where the texture will no longer be used (see main branch).

@jhoogstraat
Copy link
Owner

I changed the structure of this repo. Please use develop from now on, if you want to use v2 features.

@seth35us
Copy link
Author

Thanks, I think version 1.1.2 fixed it. I have not seen the error in this version forward, but haven't tested as extensively.

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