opentok / opentok-android-sdk-samples

Sample applications illustrating best practices using OpenTok Android SDK.
https://tokbox.com/developer/sdks/android/
MIT License
210 stars 169 forks source link

Caused by: android.util.AndroidRuntimeException: Animators may only be run on Looper threads #424

Closed rituapplocum closed 1 year ago

rituapplocum commented 2 years ago

Getting the above whenever trying to draw text on the Textureview for Multiparty Video call

textureView.surfaceTextureListener = object : TextureView.SurfaceTextureListener { override fun onSurfaceTextureAvailable( surface: SurfaceTexture?, width: Int, height: Int ) { Log.d("FragmentActivity.TAG", "called")

                var canvas: Canvas? = null
                try {
                    val text = subscriber.stream.name
                    canvas = textureView.lockCanvas()
                    synchronized(textureView) {
                        val paint = Paint()
                        paint.color = Color.RED
                        paint.textSize = 30f
                        canvas.drawText(text, 200f, 100f, paint)
                    }
                } catch (e: java.lang.Exception) {
                    Log.e("FragmentActivity.TAG", "run() lockCanvas()", e)
                } finally {
                    if (canvas != null) {
                        textureView.unlockCanvasAndPost(canvas)
                    }
                }
            }

            override fun onSurfaceTextureSizeChanged(
                surface: SurfaceTexture?,
                width: Int,
                height: Int
            ) {

            }

            override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?): Boolean =
                false

            override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {

            }

        `}```
v-kpheng commented 1 year ago

Thanks, @rituapplocum, for filing this issue.

Can you provide a stack trace exception dump, please: https://stackoverflow.com/questions/37689903/animators-may-only-be-run-on-looper-threads-android?

v-kpheng commented 1 year ago

Closing, given lack of stack trace.

Please feel free to refile if needed. Thanks!