twilio/video-quickstart-android

The app is crashing running latest 7.0.3

mykola-tarchanyn opened this issue · 23 comments

Description

After upgrading to 7.0.3 we started inconsistently seeing a crash when trying to unpublishTrack() on room's localParticipant. We couldn't reproduce the crash on 6.4.0.

The SID is RM1c42b82db0dd966521b4a314b2d696dc

Steps to Reproduce

  1. Create a Video call and publish LocalVideoTrack using publishTrack()
  2. Unpublish LocalVideoTrack using unpublishTrack()

sometimes you have to repeat the steps to get it, sometimes it happens right away.

Code

localViewVideoTrack?.let {
    room?.localParticipant?.unpublishTrack(it)// I think the crash happens here
    it.release()
    localViewVideoTrack = null
}

Logs

There weren't many logs related to this, the only thing I saw that could be related is

A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 6554 (MediaFactoryImp), pid 6073 (doximitydroid.x)

Versions

the app is targeting Android API 31 and running on Android 12 using the latest Twilio video API 7.0.3.

Video Android SDK

7.0.3

Android API

API 31

Android Device

Samsung S20 Android 12

I faced the same problem after upgrading to Android 12. I removed the lines it.release() and localViewVideoTrack = null. And I removed all the release() lines. At least it doesn't crash right now, but it's not a solution.

I faced the same problem after upgrading to Android 12. I removed the lines it.release() and localViewVideoTrack = null. And I removed all the release() lines. At least it doesn't crash right now, but it's not a solution.

Removing it.release() doesn't sound like a good idea, it will likely lead to a leak. To all my testing it looks like it's a bug in latest twilio version.

@mykola-tarchanyn & @yldrmsull Thank you for the report,

  1. are you able to reproduce this with other deices?
  2. Are you able to reproduce this with the quickstart or the Ahoy app? (https://github.com/twilio/twilio-video-app-android)
  3. Do you have a log showing the call stack?

@afalls-twilio ,

  1. Yes, we were able to reproduce it on every test device we have, Pixel 4, Pixel 6 Pro, Samsung S20, Samsung S21 Ultra etc..
  2. I'm still trying to log in to see if I can reproduce it there.
  3. Unfortunately no, there are no logs when this crash happens.

After simplifying my code even more it appears that the crash still happens when releasing an unpublished track, I feel like there's a race condition where room?.localParticipant?.unpublishTrack(track) is perhaps taking more time than it should and then we are trying to track.release() at that point still published track and then get a crash. I could be wrong though. Works fine on 6.4.0.

Please let me know if you have identified the issue on your end or I still need to dig into it more. Thanks!

@mykola-tarchanyn I have made a test application in an effort to reproduce the issue. The test application connects to a room and publishes a video track, then unpublishes it. I have been unable to reproduce the issue. Please modify the test app in an effort to repo the issue so we can fix it.

I tested it on a Google Pixel 4 (4G)..

The url to the code/demo..
https://drive.google.com/file/d/1vHt-MnzcRDRPiHSjCavMdmwGybCN3U6a/view?usp=sharing

In order to use, modify AUTH_TOKEN to point to a valid auth token and recompile...
NOTE the code that this ticket refers to causing a crash is on line MainAcktivity.kt:172

thanks @afalls-twilio , I have modified it and was able to reproduce the crash on my Pixel 6 Pro. Here's the link.

I created a simple TwilioViewCapturer that I swap with CameraCapturer when clicking on Switch button. In order to get a crash please click the Switch button multiple times. As I mentioned before, sometimes it takes 3 tries, sometimes 6 (it seems to depend on the device), but you will get the crash eventually. Let me know if you have questions about the changes I made. Thanks!

@mykola-tarchanyn What is the scope of the issue, is it that video tracks crashes on release or on switching capturers... I ask because are you able to repro it without using a custom capturer or switching capturers?

@afalls-twilio, the app I'm working on has two capturers (one for video and one view capturer). In the modified app I shared I basically copied the implementation of how I switch them. The app seems to crash on room.localParticipant?.unpublishTrack(track) when I try to unpublish one track before I create and publish another one. Not sure if that's the best implementation of my use case, but at least it works well in 6.4.0.

So far I could only reproduce it given my use case only.

@mykola-tarchanyn Thank you, I am able to repo the bug, we will investigate on our end, just as you experienced, we are not seeing much info from the log..

@afalls-twilio Any update on the above issue. I even tried by updating the twillo sdk version to 7.0.6 and the crash is still happening.

Tested on Samsung Galaxy S20(Android 12).

This issue is happening sporadically here as well, testing on Pixel 2 emulator with API 30.

Using com.twilio:video-android-ktx version 7.0.6.

I can see in the logs:

A/libc: /buildbot/src/googleplex-android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "Pure virtual function called!" failed
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 20746 (MediaFactoryImp), pid 20351 (droid.dev.debug)

It appears to happen some times (but not every time) I call

val localVideoTrack: LocalVideoTrack? = createLocalVideoTrack(context, true, cameraCapturerCompat)
// ... do other things, upon closing the view:
localVideoTrack?.release() // appears to happens here

@simenm @mykola-tarchanyn @way2jatin After a bit of debugging this issue should be fixed in 7.1.0.

thanks @afalls-twilio , the crash is fixed!

Yes, the issue is closed and i read the above, but:

I encountered the same issue using 6.4.1 with a Pixel 6 (Android 12). Happens also on 6.4.1
Is there another way to get this fixed or workarounded without upgrading to 7.1.0 ?

@cchierici you could possibly introduce a delay between after the track is unpublished and before it is released.

@cchierici you could possibly introduce a delay between after the track is unpublished and before it is released.

Yes, that works. I found your hint for this worakround in #707.
Thanks for the answer

@cchierici glad it worked, if you get a chance, please check out the demo app I made in the other thread and see if you can repo the issue with it, if not, help us make the changes needed to repo the issue so that we can fix it.
Thanks!

@afalls-twilio i can have a look to the demo app, but in my understanding you already fixed that bug with your version 7.1.0 while i am still on 6.4.1 for certain reasons.

my changes looked as follows (and i consider it as a workaround). turned out that 50ms delay was enough.

localVideoTrack?.let {
            CoroutineScope(Dispatchers.Main).launch {
                delay(50)
                it.release()
            }
}

And i had the crash on a Pixel6 running Android12, only. A Pixel 3 with Android 12 did not crash.
I had the same native crash as described here in the issue: #692 (comment)

Just a Signal6 somewhere in your native code...

hey @afalls-twilio, I originally filed this bug back in December last year. The crash is not happening anymore in 7.0.3 and up, but we just discovered that after upgrading to 7.0.3 the Android app renders a black screen after publish, unpublish and publish video track. The app works fine with 6.4.0. I tried upgrading to the latest 7.3.1 but I still get the black screen. Here's my SID - RM5057c050bfde231d4a099457603b1a62. Please advise. Thanks!

@mykola-tarchanyn are you using the KTX extension or the Java API and are you using the CameraCapturerCompat code from the QuickStart or from the Android Ahoy! App?

@mykola-tarchanyn there is a high probability its with the capaturer stopping/restarting.. can you look your adb logs for any exceptions and let us know what you see?

@mykola-tarchanyn @cchierici I am unable to reproduce the issue with 7.3.1+. I have created a sample test application in an attempt to reproduce the issue, please modify it such that the error can be reproduced.

https://drive.google.com/file/d/13wVk-SwJSvPyjIVT4FX2-yKYb_UlPDA0/view?usp=sharing

closing due to a lack of customer response