<live-pusher id='livePusher' ref="livePusher" class="livePusher" url=""
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :device-position="inWarehousePhoto" :beauty="0" :whiteness="0"
aspect="1:1" @statechange="statechange" @netstatus="netstatus" @error = "error" v-if="showLive"></live-pusher>
onUnload() {
uni.$off('onWeight', this.onWeight);
clearInterval(liveTime)
// 先移除 live-pusher 组件,触发底层销毁
try {
this.showLive = false;
} catch (e) {}
// clearTimeout(scanTimeout)
// requestTask && requestTask.abort();
this.productList=null;
this.printdetailed=null;
// 完善资源释放:停止推流、预览、关闭上下文
if(this.context) {
try {
this.stop();
this.stopPreview();
this.pause();
// this.close();
} catch(e) {
console.log('资源释放失败:', e);
}
}
}
5 个回复
Ask小助手
该bug反馈内容基本完整但存在关键缺失。BUG描述清晰说明了live-pusher在安卓APP关闭页面后内存未释放的问题,但未明确说明是否使用nvue页面(这对直播功能至关重要),且缺少内存占用具体数据、完整页面代码及设备具体型号。代码示例展示了组件使用和onUnload中的资源释放尝试,但未展示context初始化过程,无法直接复现。复现步骤过于简略(仅"重复进入页面"),难以精确操作验证。
从知识库分析,该问题可能成立但需注意:1) 知识库明确指出App平台使用live-pusher需勾选manifest.json中的LivePusher模块;2) 对于直播场景,强烈推荐使用nvue页面,因其无层级问题且性能更优;3) 用户HBuilderX版本4.76高于3.4.1,理论上支持vue页面live-pusher,但资源释放需通过uni.createLivePusherContext正确调用stop/stopPreview。用户代码中直接操作this.context可能未按规范创建上下文,导致资源未释放。建议用户:1) 确认是否使用nvue;2) 按文档使用uni.createLivePusherContext获取context;3) 在onUnload中确保先隐藏组件再调用context.stop();4) 升级至最新HBuilderX验证。若仍存在内存问题,需提供更完整的nvue实现代码和内存监测数据进一步排查。
l***@fazyun.com (作者) - 1
@DCloud_uniad_HDX
l***@fazyun.com (作者) - 1
使用的nvue页面开发
l***@fazyun.com (作者) - 1
@DCloud_uniad_HDX
l***@fazyun.com (作者) - 1
@DCloud_UNI_Anne
要回复问题请先登录或注册
公告
更多>相关问题