team-telnyx / telnyx-webrtc-android

Telnyx Android WebRTC SDK - Enable real-time communication with WebRTC and Telnyx
MIT License
13 stars 2 forks source link

[Bug] Short Bug Description #186

Closed tongsoftinfo closed 2 years ago

tongsoftinfo commented 2 years ago

Bug Category

SDK Version implementation 'com.github.team-telnyx:telnyx-webrtc-android:v1.2.12-alpha'

Describe the bug The activity is not in the display state. After the mobile phone presses the home button, the mobile phone screen is on the home page. At this time, the SocketObserver does not return information. Only when the activity is displayed again, the information can be received.

Expected behaviour In the non-display state of the activity, SocketObserver can return information normally

To Reproduce Use the Git demo

Android Device (please complete the following information):

Logs

Oliver-Zimmerman commented 2 years ago

Hi @tongsoftinfo

I will look into this. You should still receive socket messages even in the background, however the OS can sometimes kill this process (after an extended period of time). Does this happen immediately for you when the app is in the background? Or after some time?

Generally, when the OS kills this process, you should receive a Push Notification instead.

tongsoftinfo commented 2 years ago

The background socket message has information, but onMessageReceived does not return information. In the telnyx_rtc.ringing state, it can be in the background. After a period of time, you can see that the socket message has telnyx_rtc.answer information, but onMessageReceived does not return the status information of telnyx_rtc.answer

tongsoftinfo commented 2 years ago

This happens immediately when in the background

Oliver-Zimmerman commented 2 years ago

Okay, I will investigate and update this ticket.

tongsoftinfo commented 2 years ago

The MediaPlayer in TelnyxClient.kt does not use release() at the end, only stop() and reset(), is this situation correct?

Oliver-Zimmerman commented 2 years ago

The same MediaPlayer instance is overwritten each time it is used, I don't believe release is necessary however I can test if adding it causes any issues.

Are you experiencing any issues relating to this?

tongsoftinfo commented 2 years ago

app acquires a partial wake lock by calling acquire() with the PARTIAL_WAKE_LOCK flag. A partial wake lock becomes stuck if it is held for a long time while your app is running in the background (no part of your app is visible to the user). This information is the suggestion that Google returned to our APP. After I checked the corresponding code, I found this situation, so I asked your opinion on this. This is the document address given by Google : https://developer.android. com/topic/performance/vitals/wakelock

Oliver-Zimmerman commented 2 years ago

Okay, I will look into this on top of the background related stuff

Oliver-Zimmerman commented 2 years ago

@tongsoftinfo in relation to the MediaPlayer release, we have an open PR here: https://github.com/team-telnyx/telnyx-webrtc-android/pull/189

I will release a new version when it is reviewed and let you know here.

Oliver-Zimmerman commented 2 years ago

@tongsoftinfo we have released a version that releases the MediaPlayer. You can see the PR here: https://github.com/team-telnyx/telnyx-webrtc-android/pull/189

This is available in the SDK here: https://jitpack.io/#team-telnyx/telnyx-webrtc-android/v1.2.15-alpha

In regards to your original bug report. In testing I realized what you were describing. Messages come in the socket and the ringtone will play, but onMessageReceived is not fired. I initially thought you were talking about the socket receiving messages in general.

This is not a bug, and isn't something we will attempt to fix. This is actually how LiveData and MVVM works.

LiveData won't get new values if there isn't an active Observer and observers get paused when your application is minimized (they are lifecycle dependent). This is okay though because once the app is moved back to the foreground, the observer becomes active again and receives the latest posted data. This is how LiveData and Observers work.

This should be okay though, the SDK will ring and notify the user they are receiving a call (as long as a ringtone is set) and the activity will update immediately when resumed. I'm not sure why you would want the UI to update while the activity is not visible.

If you are developing your own app, there are a few things you can do here to make this more streamlined. You could look into using the ConnectionService to integrate with native OS Call UI (This is out of scope for an MVP sample app though) or alternatively an easier method would be to manually disconnect whenever the user enters the background so that they receive a Push Notification instead when the app is in the background (if you have set this up with the guide in the docs) https://developers.telnyx.com/docs/v2/webrtc/push-notifications?lang=android

tongsoftinfo commented 2 years ago

Some users are accustomed to placing the application in the background after making a call, and then using other applications, but in this case, LiveData has no information transmission, and cannot automatically perform the next operation. Place the front desk to operate, such a user experience is a very poor feeling

tongsoftinfo commented 2 years ago

I have found the corresponding processing method, I will use mTelnyxClient.getSocketResponse().observeForever() for the corresponding operation

Oliver-Zimmerman commented 2 years ago

The SDK is still receiving socket messages and working in the background. The only thing that is not updating is the UI which is okay because it is in the background. Once the app is resumed the UI will immediately update. There is no poor user experience because there is nothing for the user to experience while it is in the background.

However, if .observeForever() works in your specific use case then that's great. Remember to manually remove the observer when you clear the view model though.