Fix OHOS Worker crash and harden JsHelper error handling#3431
Merged
Conversation
…o avoid stranded entries.
…ot silently broken.
…so import raises instead of silently degrading.
…ptr is not cached.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3431 +/- ##
========================================
Coverage 81.55% 81.55%
========================================
Files 558 558
Lines 51407 51407
Branches 13875 13987 +112
========================================
+ Hits 41924 41927 +3
+ Misses 6603 6600 -3
Partials 2880 2880 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
shlzxjp
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
当 OHOS 应用从 Worker 线程导入 libpag 时,会触发 "ecma_vm cannot run in multi-thread" 致命崩溃。
根因:JsHelper 里 ConstructorRefMap 是进程级全局表、仅以 class name 为 key 共享所有 napi_env。Worker 线程进入 SetConstructor 重复注册同名 class 时,会用 Worker 自己的 env 去调用 napi_delete_reference 释放主线程 env 创建的 napi_ref,跨 EcmaVM 访问触发 abort。
本 PR 的修复分两层:
一、核心修复
二、顺手把相关错误路径补齐(review 过程中发现的配套问题)
改动仅限 src/platform/ohos/JsHelper.cpp 与 src/platform/ohos/JPAG.cpp,不影响其它平台。