flv.js icon indicating copy to clipboard operation
flv.js copied to clipboard

播放wss直播流时,devTools内存泄露(客户用起倒是没多大问题,毕竟不打开F12)

Open tangshanghai opened this issue 2 years ago • 2 comments

let urls = [ // 'wss://imo.mtooltest.chinamcloud.cn/preview-stream?source=http://liveyc.cmc.yuechirmt.cn/live/yctv.flv', 'wss://imo.mtooltest.chinamcloud.cn/preview-stream?source=rtmp://livepgc.cmc.zju.edu.cn/pgc/guodao2', 'wss://imo.mtooltest.chinamcloud.cn/preview-stream?source=rtmp://livepgc.cmc.zju.edu.cn/live/vr', ] let flvPlayers = []; for(let i=0;i<urls.length;i++){ let video = document.createElement('video'); video.style.width = '640px'; video.style.height = '360px'; document.body.appendChild(video); var flvPlayer = flvjs.createPlayer({ type: 'flv', isLive: true, url: urls[i], cors: true, withCredentials: false, },{ enableStashBuffer:false, lazyLoadMaxDuration:10, autoCleanupSourceBuffer:true, autoCleanupMaxBackwardDuration:5, autoCleanupMinBackwardDuration:2 }); flvPlayer.attachMediaElement(video); flvPlayer.load(); flvPlayer.play(); flvPlayers.push(flvPlayer); }

如果先打开网页,再打开F12,这时devTools不会发生内存泄露。但如果此时刷新页面,devTools就内存就开始涨,或者先打开一个空白网页,同时打开F12,再输入播放页,也会发生devTools内存泄露。

tangshanghai avatar Mar 28 '22 06:03 tangshanghai

你刷新页面之前要把播放器销毁

zhang421755327 avatar Sep 02 '22 02:09 zhang421755327

浏览器tab切换的时候,非激活的tab里的播放器也要销毁,激活后再重新播放

zhang421755327 avatar Sep 02 '22 02:09 zhang421755327