Closed VivekKannaV closed 5 months ago
Please note the following observation:
If we have the following code, we don't face crash at all even in v7.6.4
activeRoom?.localParticipant?.localVideoTracks?.firstOrNull()?.localVideoTrack?.release() // This line fixes the crash
activeRoom?.disconnect()
activeRoom = null
But we don't wanna add this line because activeRoom?.disconnect()
is expected to do this resource release.
Also to be noted, all works good enough without the release()
code with v7.6.1
@VivekKannaV how are you handling orientation changes in your application? are you setting android:configChanges="orientation
in the manifiest or are you letting the system tear down and restart your activity?
@afalls-twilio Yes, we're setting android:configChanges="orientation"
in the manifest.
@VivekKannaV I presume you are also setting screenSize
as well? so in your AndroidManifest looks like, android:configChanges="orientation|screenSize"
? (screenSize is needed on Android 13+).
Also, what is the logcat output?
I suspect the issue is with your app and the handling of the screen share related permissions. The room connection should not be being disconnected, and so it begs the question, why is disconnect
being called, is onDestroy(..)
being invoked? The Activities onDestroyed()
should not be being called when the devices is rotated if the configChanges
are set up correctly and onConfigurationChanged
is being handled.
I have included and updated version of the screen-share-demo that we used from the previous screen share issue filed that does not crash when rotated, even when the system permission dialog is up. [Uploading screen-share-demo.tgz…]()
@afalls-twilio
Pls find the config changes setting here. This is from our actual project
android:configChanges="screenSize|keyboardHidden|orientation|fontScale|uiMode|navigation|keyboard|fontWeightAdjustment"
To narrow it down, This is from our sample forked Twilio-video-quickstart project. (We face the same crash)
android:configChanges="orientation|screenSize"
Also, what is the logcat output?
Pls check the logs section in the very first comment
Why is disconnect being called, in onDestroy(..)?
No, we don't invoke disconnect()
in onDestroy()
@VivekKannaV thank you for the info.
I suspect that the quickstart example does not handle the case when the phone is rotated when the app is backgrounded and waiting for the user to accept the permissions needed for screen sharing. The quickstarts were intended to serve as an example, not as the complete solution.
Looking at your log, I suspect it is crashing because the intent sent to initiate the media projection service is invalid after the device is rotated..
java.lang.RuntimeException: java.lang.SecurityException: Invalid media projection
I have prepared a demo for us to go back and forth with to help reproduce the issue. I was unable to repo the issue with the demo, so please take a look, See if you can make it crash with the demo. Feel free to inspect the demo's source code to see how we handle the case when the devices is rotated when the system permissions dialog is up.
The demo is intended to be ran on two devices, where one device initiates the screen share and the other receives the screen share. As such, on line 68 & 70 of MainActivity.java, is where you put the respective tokens for each sessions and on line 72, is where you set which token is used for that instance.
The demo is located here.. https://drive.google.com/file/d/1i3dfaglxS5Nth3PFQRHnsa83BHN4APeI/view?usp=sharing Thanks!
@afalls-twilio We have a forked quick start project. I have added a couple of commits for your ref.
Please feel free to checkout the last two commits from this project that would help your team to repro this issue.
Kindly follow the steps shared in the first comment. You could repro the crash from e02d776 this commit. Also added a video that was taken from this quick start project for ref. Let us know if it helps or need more info.
Pls use the below info to join in web Link: https://twilio-dot-app-launcher-dev-5ef0fa0a.uc.r.appspot.com/ Room: Vivek23
Note: Twilio web link will be accessible for two weeks.
@VivekKannaV I cannot run your demo because it depends on being part of your firebase project, which I'm not part of.. I don't have access to your google-services.json...
Several Things.. 1) Did you get a chance to check out the demo I sent you, where the screen can be rotated without crashes? 2) Why are you releasing the video track when the device is rotated in the first place? 3) Are you failing to unpublish to track before releasing it?
Thanks
Issue has been fixed , We can go ahead close the ticket based on @VivekKannaV confirmation.
Description
Application crashes when media projection permission is ON & if we change the device orientation.
Steps to Reproduce
PF video link: https://drive.google.com/file/d/18LgT63kMRi7J2luLIBcesRFJddb7MXbD/view?usp=share_link
Expected Behavior
App stays with permission with no crash
Actual Behavior
App got crash
Reproduces how Often
100%
Code
This code will be invoked when user accepts the permission
This code will be invoked to disconnect the room
Logs
Twilio crash on orientation change.txt
Versions
KOTLIN = "1.8.21" GRADLE_TOOLS = "8.0.1" TARGET_SDK_VERSION = 33 BUILD_TOOLS_VERSION = "33.0.2" JVM_TARGET_VERSION = "17"
Video Android SDK
7.6.4 Note: We didn't face any crash with v7.6.1
Android API
TARGET_SDK = 33 Android SDK: 30, Release: 11
Android Device
Samsung Tab Active A Model: SM-T295 Hardware: qcom