Android jsi + QuickJS: worker close() from its message handler aborts in JS_FreeRuntime (gc_obj_list not empty)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start from the Android worker teardown path used when close() is called inside onmessage, then compare it with the parent terminate() path and the napi worker teardown. Trace which runtime-owned JSValues or native caches remain when JS_FreeRuntime runs. Done means the reproduced Java class, gc(), and self-close sequence exits cleanly with QuickJS and jsi.
由索引模型根据 Issue 内容生成。
描述
Summary
With the jsi binding layer on QuickJS, the app aborts when a worker calls close() from inside its onmessage handler after it has used Java classes. QuickJS asserts in JS_FreeRuntime:
Assertion failed: list_empty(&rt->gc_obj_list)
That means GC objects are still alive when the worker's runtime is freed. Something still holds JSValues owned by that runtime, such as a native cache or object map that isn't released before the runtime is freed. Other combinations don't hit it:
| Combination | Result |
|---|---|
| napi + QuickJS, same test | pass |
jsi + QuickJS, terminate() from the parent |
pass |
Reproduce
- Build
platforms/android/test-appwith QuickJS and the jsi layer:
./gradlew :app:assembleDebug -Pengine=QUICKJS -Pns_engine=QUICKJS -PbindingLayer=jsi -PonlyArm64 -PuseKotlin=true - Use a worker that touches a Java class, forces a collection, and then closes itself from the handler:
onmessage = () => { new java.lang.Object(); gc(); close(); }; - From the main runtime, create the worker and
postMessageto it. - The app aborts in
JS_FreeRuntimeon every run. A collection inside the handler is required; withoutgc(), it depends on the heap state.
This was found while testing #92. It reproduced in 3 of 3 runs with #92 applied and in 2 of 2 runs on the unmodified base branch, so #92 does not cause it.
Expected
A worker that closes itself is torn down cleanly. Every value NativeScript holds in the runtime is released before the runtime is freed, as it is when the parent calls terminate() and in the napi tree.
Environment
- Branch:
android-react-nativeat 64c7fed0 - Emulator: Android API 36, arm64
- Engine: QuickJS (quickjs-ng), with the jsi binding layer
- 主要语言
- C++
- 星标
- 27
- 派生
- 4
- 平均合并
- 16 小时 48 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/runtimes 的其他 Issue
-
bug
难度 4/5 3-5 天 新手友好度 48/100
NativeScript/runtimes#100 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 45/100
NativeScript/runtimes#99 ·
维护者通常 1 天内回复
-
bug
难度 4/5 1-2 天 新手友好度 55/100
NativeScript/runtimes#98 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 53/100
NativeScript/runtimes#97 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
NativeScript/runtimes#93 ·
维护者通常 1 天内回复
查看 NativeScript/runtimes 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
chipsalliance/verible#2644 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
grafana/pyroscope-dotnet#470 ·
维护者通常 1 天内回复
-
documentation P5 XS
难度 2/5 1-3 小时 新手友好度 72/100
open-astro/AlpacaBridge#1848 ·
维护者通常 1 天内回复
-
ai
难度 1/5 1 小时以内 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 76/100
维护者通常 3 天内回复