twilio / video-quickstart-android

Twilio Video Quickstart for Android
MIT License
212 stars 159 forks source link

Pure virtual function called 7.1.0 #707

Closed simenm closed 1 year ago

simenm commented 2 years ago

Description

After following the progress in https://github.com/twilio/video-quickstart-android/issues/692 I updated to 7.1.0, and my app is crashing when I try to dispose of my local video track. Interestingly it only seems to happen if I "have joined a twilio room", and am streaming video between two participants. I've so far only been able to reproduce on emulator, which is running Pixel 2 with API 30. Testing on an older device of mine does not produce the error.

See details below, please let me know if I can provide any other useful information.

Steps to Reproduce

step 1 create video track

localVideoTrack = createLocalVideoTrack(context, true, cameraCapturerCompat)

step 2 join a twilio room

roomListener = {
   ...
   private fun addRemoteParticipant(remoteParticipant: RemoteParticipant) {
    } else {
        remoteParticipant.remoteVideoTracks.firstOrNull()?.let { remoteVideoTrackPublication ->
            if (remoteVideoTrackPublication.isTrackSubscribed) {
                remoteVideoTrackPublication.remoteVideoTrack?.let { addRemoteParticipantVideo(it) }
            }
        }
        remoteParticipant.setListener(participantListener)
    }
}

twilioRoom = Video.connect(context, token, roomListener) {
    roomName("12345")
    audioTracks(listOf(localAudioTrack))
    videoTracks(listOf(localVideoTrack))
}

step 3 dispose the video upon disposing the view

DisposableEffect(true) {
    onDispose {
        twilioRoom?.disconnect()
        localAudioTrack?.release()
        localVideoTrack?.release() // crash happens because of this call
    }
}

Expected Behavior

Gracefully disposing of the video track

Actual Behavior

The app crashes with a A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15065 (MediaFactoryImp), pid 14540 (droid.dev.debug)

Reproduces how Often

Every time

Logs

SEE PASTEBIN FOR COMPLETE LOGS

    2022-03-24 14:40:48.713 411-584/? I/CameraService: disconnect: Disconnected client for camera 1 for PID 14540
    2022-03-24 14:40:48.713 14540-15071/com.my.company.android.dev.debug I/tvi.webrtc.Logging: Camera2Session: Stop done
    2022-03-24 14:40:48.713 14540-15071/com.my.company.android.dev.debug I/tvi.webrtc.Logging: GlShader: Deleting shader.
    2022-03-24 14:40:48.727 14540-15106/com.my.company.android.dev.debug I/tvi.webrtc.Logging: WebRtcAudioTrack: Calling AudioTrack.stop...
    2022-03-24 14:40:48.727 14540-15106/com.my.company.android.dev.debug D/AudioTrack: stop(185): called with 183897 frames delivered
    2022-03-24 14:40:48.728 14540-15106/com.my.company.android.dev.debug I/tvi.webrtc.Logging: WebRtcAudioTrack: AudioTrack.stop is done.
    2022-03-24 14:40:48.728 14540-15066/com.my.company.android.dev.debug I/tvi.webrtc.Logging: WebRtcAudioTrack: AudioTrackThread has now been stopped.
    2022-03-24 14:40:48.728 14540-15066/com.my.company.android.dev.debug I/tvi.webrtc.Logging: WebRtcAudioTrack: releaseAudioResources
    2022-03-24 14:40:48.735 14540-15065/com.my.company.android.dev.debug 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
    2022-03-24 14:40:48.735 14540-15065/com.my.company.android.dev.debug A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15065 (MediaFactoryImp), pid 14540 (droid.dev.debug)
    2022-03-24 14:40:48.772 520-978/? I/system_server: oneway function results will be dropped but finished with status OK and parcel size 4
    2022-03-24 14:40:48.810 15129-15129/? I/crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
    2022-03-24 14:40:48.810 283-283/? I/tombstoned: received crash request for pid 15065
    2022-03-24 14:40:48.811 15129-15129/? I/crash_dump32: performing dump of process 14540 (target tid = 15065)
    2022-03-24 14:40:48.817 15129-15129/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    2022-03-24 14:40:48.817 15129-15129/? A/DEBUG: Revision: '0'
    2022-03-24 14:40:48.817 15129-15129/? A/DEBUG: ABI: 'x86'
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG: Timestamp: 2022-03-24 14:40:48+0100
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG: pid: 14540, tid: 15065, name: MediaFactoryImp  >>> com.my.company.android.dev.debug <<<
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG: uid: 10197
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG: Abort message: '/buildbot/src/googleplex-android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "Pure virtual function called!" failed'
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG:     eax 00000000  ebx 000038cc  ecx 00003ad9  edx 00000006
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG:     edi e6bf581e  esi b511ee70
    2022-03-24 14:40:48.818 15129-15129/? A/DEBUG:     ebp ea5e6b90  esp b511ee18  eip ea5e6b99
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG: backtrace:
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #00 pc 00000b99  [vdso] (__kernel_vsyscall+9)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #01 pc 0005ad68  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 6e3a0180fa6637b68c0d181c343e6806)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #02 pc 00076511  /apex/com.android.runtime/lib/bionic/libc.so (abort+209) (BuildId: 6e3a0180fa6637b68c0d181c343e6806)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #03 pc 00076a28  /apex/com.android.runtime/lib/bionic/libc.so (__assert2+56) (BuildId: 6e3a0180fa6637b68c0d181c343e6806)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #04 pc 00bf6064  /data/app/~~wiaJ7667Y0Nm922n5-lIPg==/com.my.company.android.dev.debug-WMeev-z0A-DHErGJC6Megw==/base.apk!libtwilio_video_android_so.so (offset 0x92c000) (BuildId: a68f1839b7c7aabe7d57207b840fe6b924a95126)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #05 pc 00bf3aa3  /data/app/~~wiaJ7667Y0Nm922n5-lIPg==/com.my.company.android.dev.debug-WMeev-z0A-DHErGJC6Megw==/base.apk!libtwilio_video_android_so.so (offset 0x92c000) (__cxa_pure_virtual+35) (BuildId: a68f1839b7c7aabe7d57207b840fe6b924a95126)
    2022-03-24 14:40:48.868 15129-15129/? A/DEBUG:       #06 pc 00691085  /data/app/~~wiaJ7667Y0Nm922n5-lIPg==/com.my.company.android.dev.debug-WMeev-z0A-DHErGJC6Megw==/base.apk!libtwilio_video_android_so.so (offset 0x92c000) (BuildId: a68f1839b7c7aabe7d57207b840fe6b924a95126)

Video Android SDK

7.1.0

Android API

API 30

Android Device

Emulator running Pixel 2 API 30

afalls-twilio commented 2 years ago

@simenm Thank you for the bug report, yeah, the issue fixed in 7.10 was for audio tracks, not video tracks... Is onDispose being called on the same thread as the one calling Video.connect(..)?

inferpse commented 2 years ago

Hi @afalls-twilio ! Are you aware about any plans to fix this issue? Or maybe you could suggest a workaround to avoid app crash? Thank you.

afalls-twilio commented 2 years ago

Hi all, sorry for the delayed response we have some large updates coming down the pipe and we will take a look at this as soon as we can. As for this issue regarding the video track crash, if the root cause is similar to the issue with the audio tracks crashing upon "unpublish & release", then a possible workaround is delay the release call... the simplest way to do this is to schedule the release on the ui thread after you have unpublished.

afalls-twilio commented 1 year ago

@inferpse @simenm We are having trouble reproducing the issue, I have created a test application which we can use to attempt to recreate the issue with. The application currently publishes/unpublishes in a loop. Please modify the test application to help us reproduce it.

PS: I ran it both on a Pixel 2 API 30 (x86) emulator & Pixel 4a device with API 31

https://drive.google.com/drive/folders/1Y-SMX8Op8xUbhtTP_kd4QPt1uuw1LASr?usp=sharing

afalls-twilio commented 1 year ago

@inferpse @simenm have you had a chance to test/reproduce with the test app & src provided?

inferpse commented 1 year ago

@afalls-twilio sorry for the delay. I'm not actually an Android developer so I had to wait for an opportunity to reproduce this issue with the person who originally pointed me here.

Around a month ago we applied the workaround that you suggested in our application and it resolved the app crash for us. Today we've spent some time trying to reproduce the crash using both physical devices and emulators but we did not encounter that crash anymore.

So unfortunately I'm not sure that we could give more insights on this.

afalls-twilio commented 1 year ago

@inferpse Thank you for the update, if we don't hear back from @simenm about the issue, I'll just close it and assume it was fixed when we fixed a very similar issue in the recent past.