l***@fazyun.com
l***@fazyun.com
  • 发布:2026-01-12 20:56
  • 更新:2026-01-12 21:00
  • 阅读:31

【报Bug】live-pusher组件在安卓APP中,关闭页面不会释放内存

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 26.2

HBuilderX类型: 正式

HBuilderX版本号: 4.76

手机系统: Android

手机系统版本号: Android 7.1.1

手机机型: 固件

页面类型: nvue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<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);  
            }  
        }  

}

操作步骤:

重复进入页面,内存会一直占用

预期结果:

关闭后一段时间自动回收

实际结果:

内存会一直占用

bug描述:

<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>

一个页面包含了这个组件后,内存会一直占有,除非杀死APP,如果去掉这个组件就正常

2026-01-12 20:56 负责人:无 分享
已邀请:
Ask小助手

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实现代码和内存监测数据进一步排查。

内容为 AI 生成,仅供参考
l***@fazyun.com

l***@fazyun.com (作者) - 1

@DCloud_uniad_HDX

l***@fazyun.com

l***@fazyun.com (作者) - 1

使用的nvue页面开发

l***@fazyun.com

l***@fazyun.com (作者) - 1

@DCloud_uniad_HDX

l***@fazyun.com

l***@fazyun.com (作者) - 1

@DCloud_UNI_Anne

要回复问题请先登录注册