HarmonyOS鸿蒙Next中BUG?Arengine SDK 内部崩溃!
HarmonyOS鸿蒙Next中BUG?Arengine SDK 内部崩溃! Arengine SDK 内部崩溃:arview.ts:753 在首次有效位姿获取时访问 undefined.ARType。崩溃堆栈里的源码路径:/usr1/hmos_for_system/src/increment/sourcecode/vendor/huawei/domains/ar/ar_view/api/ets/arview.ts:753
设备:HUAWEI Mate 60 Pro+ (ALN-AL10)
HarmonyOS 版本:6.1.0.117
SDK:API 12 (DevEco Studio 6.0.2, apiTargetVersion 60002022)
问题:ARType.WORLD 模式下,ARView 组件在首次获得有效 SLAM 跟踪位姿时崩溃。init() 成功,相机预览正常显示约 2 秒,当 updateResult.pose.length 从 1 变为 8(首次有效位姿)时,SDK 内部 arview.ts:753 访问 updateResult.pose[i].ARType 时 pose[i] 为 undefined,导致 TypeError 崩溃。
关键日志:
-
[ar_instant_slam_device.cpp 354] slam get display pose success
-
onFrameUpdate, updateResult.pose.length=8
-
TypeError: Cannot read property ARType of undefined at onFrameUpdate (arview.ts:753:1)
尝试过以下方案均无效:
-
全量 ARConfig 8 字段
-
空 Scene + 无 callback
-
NavDestination + onAppear 延迟初始化
-
精简配置仅 type:WORLD
这是一个 SDK 内部空值检查缺失问题。崩溃在 SDK 内部 onFrameUpdate 方法中,与应用层代码无关。最小复现代码在附件 txt 中。请华为 AREngine 团队在 arview.ts 的 onFrameUpdate 方法中对 pose[i] 增加空值检查。
附加错误日志:
- SetLogicCameraWhiteListState failed, ret = 7400102(持续出现)
AREngine SDK Bug Report — arview.ts:753 崩溃
| 字段 | 值 |
|---|---|
| Bug 类型 | AREngine SDK 内部空指针崩溃 |
| 严重级别 | P0 / Critical(应用无法启动 AR) |
| 影响范围 | 所有使用 ARType.WORLD 的 AR 应用 |
| 设备 | HUAWEI Mate 60 Pro+ (ALN-AL10) |
| HarmonyOS 版本 | 6.1.0.117 (OpenHarmony-6.1.0.115) |
| SDK 版本 | DevEco Studio 6.0.2, API 12 (60002022) |
| 芯片 | Kirin 9000s |
| 崩溃源文件 | arview.ts:753(SDK 内部代码,vendor/huawei/domains/ar/ar_view/api/ets/) |
崩溃堆栈
TypeError: Cannot read property ARType of undefined
at onFrameUpdate (/usr1/hmos_for_system/src/increment/sourcecode/vendor/huawei/domains/ar/ar_view/api/ets/arview.ts:753:1)
#00 pc 000000000036176c libark_jsruntime.so
#01 pc 000000000035f488 libark_jsruntime.so
#16 pc 000000000007a484 libace_napi.z.so (napi_call_function)
#17 pc 0000000000008d98 libdisplaysync.z.so
#18 pc 0000000000b4b6bc libace_compatible.z.so (UIDisplaySync::OnFrame)
#20 pc 0000000001975300 libace_compatible.z.so (NG::PipelineContext::FlushVsync)
#23 pc 00000000000562e8 libwmutil.z.so (VsyncStation::VsyncCallbackInner)
重现步骤
最小复现代码
// 最简 ARView 测试,无需 callback
import { ARView, arViewController, arEngine } from '@kit.AREngine';
import { Scene } from '@kit.ArkGraphics3D';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
@Entry
@Component
struct MinimalTest {
@State arContext?: arViewController.ARViewContext;
async aboutToAppear() {
// 申请权限
const atManager = abilityAccessCtrl.createAtManager();
await atManager.requestPermissionsFromUser(
this.getUIContext().getHostContext(),
['ohos.permission.CAMERA']
);
// 创建空 Scene
const scene = await Scene.load();
// 创建 ARContext
const ctx = new arViewController.ARViewContext();
ctx.config = { type: arEngine.ARType.WORLD };
ctx.scene = scene;
// 注意:不设 callback
await ctx.init();
this.arContext = ctx;
}
build() {
Stack() {
if (this.arContext) {
ARView({ context: this.arContext! })
.width('100%')
.height('100%')
}
}
}
}
重现条件
- 设备:Mate 60 Pro+ (HarmonyOS 6.1.0.117)
- SDK:API 12 (DevEco Studio 6.0.2)
- AR 类型:
ARType.WORLD - 崩溃时机:首次有效位姿获取时
关键日志
[ar_instant_slam_device.cpp 354] slam get display pose success, failed time is :35
[ARViewContext] onFrameUpdate, updateResult.pose.length=8 ← pose 从 1 变为 8
TypeError: Cannot read property ARType of undefined ← 崩溃
at onFrameUpdate (arview.ts:753:1)
根因分析
SDK 内部 arview.ts 的 onFrameUpdate 方法中,在遍历 updateResult.pose 数组时,访问了 pose[i].ARType。但首次有效位姿返回后(pose.length 从 1 变为 8),数组中某个元素 pose[i] 为 undefined,导致崩溃。
热点代码位置推测(arview.ts 第 753 行附近):
// 内部代码大致逻辑(基于崩溃推测)
for (let i = 0; i < updateResult.pose.length; i++) {
// 第 753 行附近,缺少空值检查
const trackableType = updateResult.pose[i].ARType; // ← pose[i] 为 undefined
// ... 后续处理
}
关键线索
- 触发时机:SLAM 首次成功获取跟踪位姿时(
slam get display pose success) - pose.length 变化:从 1(跟踪未就绪)→ 8(首次有效位姿),其中可能包含 feature points 或 trackable 数据
pose[i]在长度 8 的数组中存在 undefined 元素- 应用层设置 callback 与否不影响崩溃(因为崩溃在 SDK 内部
onFrameUpdate)
尝试过的绕行方案(均无效)
| 尝试 | 结果 |
|---|---|
只设 type: WORLD,无 scene |
❌ init 失败 "Graphics3D AR scene required" |
| 全量配置 8 字段 + callback | ❌ 同一崩溃点 |
| 空 Scene + 无 callback | ❌ 同一崩溃点 |
| NavDestination + onAppear 延迟初始化 | ❌ 同一崩溃点 |
| 精简配置(仅 type + powerMode) | ❌ 同一崩溃点 |
额外错误日志
运行期间持续出现的系统级错误(可能相关):
E [ar_ndk_camera.cpp 915] SetLogicCameraWhiteListState, get use logic camera failed, ret = 7400102
E [ar_session_core.cpp 569] session resume but not connect, statue[0]
W [ar_world_device.cpp 419] points data is invalid!
W [ar_preview_device.cpp 107] preview push image timestap=...
期望行为
- ARType.WORLD 模式下,首次获得有效跟踪位姿时不应崩溃
updateResult.pose数组中的元素不应包含undefined- SDK 内部应在访问
pose[i].ARType前做空值检查
附件
- 完整崩溃日志可通过 DevEco Studio Log 面板获取
- 测试项目源码可提供
报告生成时间:2026-04-27 23:55 GMT+8 测试人:tttym
更多关于HarmonyOS鸿蒙Next中BUG?Arengine SDK 内部崩溃!的实战教程也可以访问 https://www.itying.com/category-93-b0.html
兄弟,
我和你一模一样的crash。而且我前两天(4月28日)还不crash呢,好像手机自动升级系统之后,就100% crash。
更多关于HarmonyOS鸿蒙Next中BUG?Arengine SDK 内部崩溃!的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
该崩溃是 AREngine SDK 内部缺陷:首次获得有效 SLAM 位姿时,updateResult.pose 数组长度突变(1→8),但部分元素为 undefined,而 arview.ts:753 未做空值校验,直接访问 .ARType 导致 TypeError。这与应用层配置无关,属于 SDK 空指针保护缺失。
临时绕过方案(可能有效):
在 ARViewContext.config 中显式关闭所有 Trackable 类型,防止 SDK 内部填充无效的 trackable pose 元素:
ctx.config = {
type: arEngine.ARType.WORLD,
powerMode: arEngine.ARPowerMode.NORMAL, // 必填
focusMode: arEngine.ARFocusMode.AUTO, // 必填
lightingMode: arEngine.ARLightingMode.AMBIENT, // 必填
trackable: {
plane: false,
image: false,
hand: false,
body: false,
face: false
}
};
若仍崩溃,说明缺陷更深层,需等待 AREngine 团队修复 arview.ts 中的空值判断(建议附上报错日志在华为开发者论坛反馈)。


