mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-20 16:54:25 +00:00
Close WebRTC connections on disconnect
Not closing RTCPeerConnection and co will cause eventually high processor load in Chrome. Also, Chrome has some GC issues related to WebRTC, see: https://bugs.chromium.org/p/chromium/issues/detail?id=825576.
This commit is contained in:
parent
ad822a624d
commit
24ff0f2ea2
3 changed files with 25 additions and 3 deletions
|
|
@ -134,10 +134,10 @@
|
|||
<script src="/static/js/room.js?v=3"></script>
|
||||
<script src="/static/js/network/ajax.js?v=3"></script>
|
||||
<script src="/static/js/network/socket.js?v=4"></script>
|
||||
<script src="/static/js/network/rtcp.js?v=3"></script>
|
||||
<script src="/static/js/network/rtcp.js?v=4"></script>
|
||||
<script src="/static/js/recording.js?v=1"></script>
|
||||
<script src="/static/js/stats/stats.js?v=2"></script>
|
||||
<script src="/static/js/controller.js?v=6"></script>
|
||||
<script src="/static/js/controller.js?v=7"></script>
|
||||
<script src="/static/js/input/keyboard.js?v=5"></script>
|
||||
<script src="/static/js/input/touch.js?v=3"></script>
|
||||
<script src="/static/js/input/joystick.js?v=3"></script>
|
||||
|
|
|
|||
|
|
@ -449,6 +449,7 @@
|
|||
event.sub(CONNECTION_CLOSED, () => {
|
||||
input.poll().disable();
|
||||
socket.abort();
|
||||
rtcp.stop();
|
||||
});
|
||||
event.sub(LATENCY_CHECK_REQUESTED, onLatencyCheck);
|
||||
event.sub(GAMEPAD_CONNECTED, () => message.show('Gamepad connected'));
|
||||
|
|
@ -472,4 +473,4 @@
|
|||
|
||||
// initial app state
|
||||
setState(app.state.eden);
|
||||
})(document, event, env, gameList, input, KEY, log, message, recording, room, settings, socket, stats, stream, utils);
|
||||
})(document, event, env, gameList, input, KEY, log, message, recording, room, rtcp, settings, socket, stats, stream, utils);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,26 @@ const rtcp = (() => {
|
|||
}
|
||||
}
|
||||
|
||||
const stop = () => {
|
||||
if (mediaStream) {
|
||||
mediaStream.getTracks().forEach(t => {
|
||||
t.stop();
|
||||
mediaStream.removeTrack(t);
|
||||
});
|
||||
mediaStream = null;
|
||||
}
|
||||
if (connection) {
|
||||
connection.close();
|
||||
connection = null;
|
||||
}
|
||||
if (inputChannel) {
|
||||
inputChannel.close();
|
||||
inputChannel = null;
|
||||
}
|
||||
candidates = Array();
|
||||
log.info('[rtcp] WebRTC has been closed');
|
||||
}
|
||||
|
||||
const ice = (() => {
|
||||
const ICE_TIMEOUT = 2000;
|
||||
let timeForIceGathering;
|
||||
|
|
@ -165,5 +185,6 @@ const rtcp = (() => {
|
|||
isConnected: () => connected,
|
||||
isInputReady: () => inputReady,
|
||||
getConnection: () => connection,
|
||||
stop,
|
||||
}
|
||||
})(event, socket, env, log);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue