AgoraIO / Advanced-Video

MIT License
261 stars 336 forks source link

Continues data consumption after finishing the video calls #213

Closed ArcherEmiya05 closed 3 years ago

ArcherEmiya05 commented 4 years ago

Describe the bug I observe such a bit huge continues data consumption even after finishing the call session, in order to return back to normal data consumption I need to clear the app from recent tab or by doing force stop work as well. This is what I observe while testing the sample app with mobile data while this behavior seems consistent every time I run a test. Can you check it as well in your side, maybe there is a left task going on even after leaving the channels with SDK? What I suspect is because of not calling RtcEngine.destroy(); after leaving the channel since this line is only called in onTerminate() of an Application class which explain why removing the app from recent tab fix the issue, but as I read on some SO related topic that onTerminate() should not be use in production or at least stop relying on it.

To Reproduce Steps to reproduce the behavior: Tested on sample video (encrypted specifically)

Expected behavior Should no longer have a bit huge of internet data consumption after leaving the channel and stopping any process related to call.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Test the sample apps on device that can show data or network speed/usage like the one in status bar of most new Android device model. I noticed that the speed/usage only went down when I completely kill the app process like force stop or removing the app from recent tabs is sometimes enough. Speaking of recent tab another big problem is when the app is not running or open before then I use FCM for push notif. with a setFullScreenIntent where it will allow you to show activity even the screen is locked this is to answer an incoming call between devices, since setFullScreenIntent is an activity that is a single task, the app will not be added in the recent tab thus even after dropping the call on both users will leave a continues data consumption problem. I am pretty sure that leave channel is always called before finishing the activities and this data consumption issue shows only while testing and running the app.

plutoless commented 4 years ago

which demo are you looking at? you can call muteRemoteVideoStream to stop receiving any remote stream, or you can exit the channel to stop publishing/subscribing stream data

ArcherEmiya05 commented 4 years ago

I am testing the video-encryption sample, I tried to replicate the sample even leave channel method was called as well as closing the activity and the camera it still consumes huge data unless killed the app process itself. Is there anything left that needs to be trigger in SDK?

plutoless commented 4 years ago

no if you called leave channel there should be no more data in/out. could you pls help grab the sdk log for me? it's usually based on sdcard/android/data/ folder.

ArcherEmiya05 commented 4 years ago

It seems that this issue is not present in Basic Video Call sample so maybe there is something that is being left causing a bigger data consumption? Maybe its the packet_processing_plugin_jni library that is used in PacketProcessor.class causing the issue because when I completely kill the app only then the data usage/load went from 100-300+kb down to 0.7+kb which indicates that there is something left or wrong?

Latest log from my app. agorasdk.log

Latest log from Advance Video Encryption sample

(Device 1) agorasdk.log agora-rtc.log

(Device 2) agorasdk.log agorasdk_1.log

plutoless commented 4 years ago

it seems it's doing last mile test, doing these test will consume your network data usage.

INFO (18: 4:20:153 | 0) 20939; onAudioStatusChanged enable audio INFO (18: 4:20:153 | 0) 20939; [nettest] last mile test enabled INFO (18: 4:20:156 | 3) 20939; [vocs] vocs initialized INFO (18: 4:20:156 | 0) 20939; [vocs] selected: 50.17.126.121:8000 INFO (18: 4:20:158 | 2) 20939; tcp_client connecting 50.17.126.121:8000 INFO (18: 4:20:158 | 0) 20939; [vocs] request vos list....... INFO (18: 4:20:158 | 0) 20939; [vocs] selected: 3.0.163.78:1080 INFO (18: 4:20:158 | 0) 20939; [vocs] request vos list....... INFO (18: 4:20:158 | 0) 20939; [vocs] selected: 106.14.12.130:25000 INFO (18: 4:20:158 | 0) 20939; [vocs] request vos list....... INFO (18: 4:20:158 | 0) 20939; [rp] {"che.video.watermark":{"type":0}} ERROR (18: 4:20:158 | 0) 20939; failed to leave channel due to NOT in CALL ERROR (18: 4:20:158 | 0) 20939; failed to leave channel due to NOT in CALL INFO (18: 4:20:158 | 0) 20939; [rp] {"che.video.watermark":{"type":0}} INFO (18: 4:20:158 | 0) 20939; [rp] {"che.video.watermark":{"type":0}} INFO (18: 4:20:191 | 33) 20939; [vocs/t] tcp find vos connected with 0x6fae64b880 INFO (18: 4:20:191 | 0) 20939; [vocs] tcp - request vos list....... INFO (18: 4:20:283 | 92) 20939; [vocs/u] responsed from 3.0.163.78:1080, 3 vos refreshed INFO (18: 4:20:476 | 193) 20939; [vocs/u] responsed from 50.17.126.121:8000, 3 vos refreshed INFO (18: 4:20:488 | 12) 20818; API call to enable network test INFO (18: 4:20:488 | 0) 20939; [rp] {"rtc.lastmile_test":true} INFO (18: 4:20:987 | 499) 20939; [vocs/u] responsed from 106.14.12.130:25000, 3 vos refreshed INFO (18: 4:24:909 | 0) 20939; [rs] All - total: 159/159, valid: 154/154 INFO (18: 4:24:909 | 0) 20939; [rs] Counter - total: 73/73, valid: 73/73 INFO (18: 4:24:909 | 0) 20939; [rs] Event - total: 86/86, valid: 81/81 INFO (18: 4:29:924 | 15) 20939; [rs] report stats: seq: 186, report list size 0, tx/rx: 30163/8928, cache size: 0 INFO (18: 4:29:924 | 0) 20939; [rs] report server1: 199.190.44.135:8913

plutoless commented 4 years ago

i think it has nothing to do with the plugin jni class. could you pls check where you may have enabled the last mile test?

ArcherEmiya05 commented 4 years ago

It was fix by calling these methods when a call session ends:

rtcEngine().muteLocalVideoStream(true); rtcEngine().enableLocalVideo(false); rtcEngine().disableVideo(); rtcEngine().muteLocalAudioStream(true); rtcEngine().enableLocalAudio(false); rtcEngine().disableAudio();

The only thing I don't get is why this issue happens only in video encrypted sample and not on other sample like group video call while both of the samples does not call these methods and only leaveChannel is enough.

ArcherEmiya05 commented 4 years ago

My remaining question is does calling enableAudio() or disableAudio() will reset only the engine according to documentation or reset the last value passed as well on these following method?

enableLocalAudio muteLocalAudioStream muteRemoteAudioStream muteAllRemoteAudioStreams

Same question as calling enableVideo() or disableVideo()

Example scenario:

Whenever a new session start I will call enableAudio() but before that I have already a settings that set enableLocalAudio to false and muteLocalAudioStream to true. Does invoking enableAudio() will change the previous state of enableLocalAudio and muteLocalAudioStream?

plutoless commented 4 years ago

enableAudio/disableAudio will turn on/off all audio modules. so it will affect enableLocalAudio and muteLocalAudioStream yes. make sure you call enableLocalAudio/muteLocalAudioStream after you call enableAudio/disableAudio

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.