OpenVidu / openvidu-tutorials

OpenVidu tutorials to get started
http://openvidu.io/tutorials
Apache License 2.0
228 stars 251 forks source link

Call `leaveSession()` twice will make an ANR in android #115

Closed dannyZhou closed 3 years ago

dannyZhou commented 4 years ago

https://github.com/OpenVidu/openvidu-tutorials/blob/93357b263b799c7e0ac0a262c927187dad12e6b6/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/openvidu/Session.java#L197

Call leaveSession() twice will make an ANR in android.

Caused by peerConnection.close(); call twice will make ANR.

See: https://bugs.chromium.org/p/webrtc/issues/detail?id=6924

Try fix: https://github.com/OpenVidu/openvidu-tutorials/blob/93357b263b799c7e0ac0a262c927187dad12e6b6/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/openvidu/Session.java#L210

Add remoteParticipants.clear() before this line.

https://github.com/OpenVidu/openvidu-tutorials/blob/93357b263b799c7e0ac0a262c927187dad12e6b6/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/openvidu/Participant.java#L87

After this, add this.peerConnection = null;

May be fix this bug.

Sorry my English is poor.

Ayman99Shaaban commented 4 years ago

in SessionActivity.java edit leaveSession by using try/catch public void leaveSession() { try { this.session.leaveSession(); this.httpClient.dispose(); viewToDisconnectedState(); } catch (Exception ignore) { } }

and best wishes, can you help me here please

CSantosM commented 3 years ago

This issue has been fixed on commit a3ee7df193b992bd617a05bca6449ddef7d3cf0c