uni-app APP使用nvue页面live-pusher的startPreview方法会导致APP闪退

uni-app APP使用nvue页面live-pusher的startPreview方法会导致APP闪退 产品分类| uniapp/App PC开发环境操作系统| Mac PC开发环境操作系统版本号| Mac min Apple M1 HBuilderX类型| 正式 HBuilderX版本号| 4.87 手机系统| Android 手机系统版本号| Android 16 手机厂商| 小米 手机机型| REDMI K80 Pro 页面类型| nvue vue版本| vue2 打包方式| 云端 项目创建方式| HBuilderX

bug描述:

在nvue页面中使用live-pusher组件做自定义拍照,然后执行startPreview方法会导致APP闪退

示例代码:

<template>  
<view>  
<live-pusher  
v-once  
id="livePusher"  
ref="livePusher"  
class="livePusher"  
url=""  
mode="SD"  
muted="true"
enable-camera="true"
auto-focus="true"
beauty="1"
        whiteness="2"
        aspect="9:16"
        @statechange="statechange"
        @netstatus="netstatus"
        @error="error"
    ></live-pusher>
    <button class="btn" @click="startPreview">开启摄像头预览</button>
</view>
</template>  

<script>
export default {
data() {
return {
context: null
}
},
onReady() {
// 注意:需要在onReady中 或 onLoad 延时
this.context = uni.createLivePusherContext('livePusher', this)
},
methods: {
statechange(e) {
console.log('statechange:' + JSON.stringify(e))
},
netstatus(e) {
console.log('netstatus:' + JSON.stringify(e))
},
error(e) {
console.log('error:' + JSON.stringify(e))
},
startPreview() {
console.log('000', this.context.startPreview)
this.context.startPreview({
complete: (res) => {
console.log(res)
}
})
}
}
}
</script>

<style></style>

更多关于uni-app APP使用nvue页面live-pusher的startPreview方法会导致APP闪退的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app APP使用nvue页面live-pusher的startPreview方法会导致APP闪退的实战教程也可以访问 https://www.itying.com/category-93-b0.html


该问题请在专业群( uni-app 官方技术交流群 1 ) 咨询,群中有相关专业的管理员和群友。

【官方评审意见】
一、反馈完整性评估

标题与描述:已明确“nvue + live-pusher.startPreview → 闪退”,但缺少关键日志(如 logcat 崩溃堆栈)。
代码示例:可直接运行,已给出最小复现页面。
复现步骤:仅一句“在 nvue 页面运行该代码然后点击按钮”,缺少 • manifest.json 是否已勾选 LivePusher 模块 • 是否已授予摄像头权限 • 是否已连接有效推流地址(url 为空是否允许)
分类信息:完整,但 Android 16 为开发者预览版,需确认是否仅在 Android 16 出现。

二、是否真 Bug

版本:HBuilderX 4.87 为最新正式版,排除旧版已知缺陷。
已知缺陷: • release-archive 2.6.8 曾修复 “nvue 纯 nvue 模式 uni.relaunch 闪退”,但未提及 startPreview 闪退。 • live-pusher 文档明确 nvue 支持,且官方示例同样调用 startPreview,理论上应正常。
因此需进一步信息才能判定为框架 Bug,当前更可能是权限 / 配置 / 空 url 导致 native 崩溃。

三、建议补充信息

请提供 logcat 崩溃日志(关键字:libweex、liblive、camera)。
确认 manifest.json → App 模块权限 → 已勾选 “LivePusher(直播推流)”。
在小米系统设置 → 应用权限 → 摄像头/录音 已允许。
尝试给 url 赋一个有效 RTMP 地址(如 rtmp://test),看是否仍闪退。
若仅在 Android 16 出现,请换 Android 13/14 真机对比验证。

四、临时替代方案 如急需绕过,可改用 plus.video.LivePusher 原生 API(需条件编译),或使用官方推荐的 uni-live 插件。
五、结论 反馈基本完整,但缺少日志与权限确认,尚不能 100 % 认定为框架 Bug。请先按上述补充信息,若仍复现,请把 logcat 日志与 manifest 配置贴到 issue 中继续跟进。

回到顶部