napi backend: incoming ObjC blocks are bridged without retention — async completion/decision handlers die after the delegate returns
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- cpp, objective-c
- 领域
- backend
调研方向
The payload names no files. Start from the code that marshals incoming ObjC block parameters into JS FunctionPointer values, and check whether it retains the block. The fix must either copy the block (_Block_copy, released when the JS handle is released) or document the call-before-return limit. Done means an async JS call to a completion handler still works after the delegate returns, without the WebKit CompletionHandlerCallChecker abort. The maintainers have not chosen between copying and documenting, so confirm that choice before writing code.
由索引模型根据 Issue 内容生成。
描述
Summary
ObjC blocks that arrive as method parameters — completion handlers and decision handlers — are marshalled to JS as FunctionPointers over the raw NSBlock*, with no _Block_copy/retention. The block is only guaranteed alive for the duration of the delegate call; a JS caller that invokes it asynchronously — the standard pattern for WKUIDelegate runJavaScript*Panel/openPanel handlers, webView:requestMediaCapturePermissionFor… decisions, photo/auth completion handlers, and the like — dereferences a dead block. WebKit's CompletionHandlerCallChecker then aborts the process ("completion handler was not called") when its block deallocates un-invoked.
Expected
Either copy incoming blocks when marshalling them to JS — so a JS-held FunctionPointer keeps the handler alive until explicitly released — or expose/document the call-before-return constraint. Today the pointer looks callable indefinitely; there is no lifetime signal until the abort.
Workaround we run: grab the raw pointer (__ns_native_ptr) and _Block_copy/_Block_release around the async call window.
Environment
NativeScript/runtimes5b697b39, generic napi backend,TARGET_PLATFORM=macos(the same block-marshalling path ships in the iOS napi runtime, where asyncWKUIDelegate/PHPhotoLibrary-style completions hit the same lifetime gap)
- 主要语言
- C++
- 星标
- 27
- 派生
- 4
- 平均合并
- 5 天 11 小时
- 30 天内合并 PR
- 12
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/runtimes 的其他 Issue
-
难度 5/5 一周以上 新手友好度 22/100
NativeScript/runtimes#110 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 32/100
NativeScript/runtimes#109 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 18/100
NativeScript/runtimes#108 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 40/100
NativeScript/runtimes#107 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 42/100
NativeScript/runtimes#106 ·
维护者通常 1 天内回复
查看 NativeScript/runtimes 的全部 Issue
相似的 Issue
-
Code: Performance
难度 1/5 1 小时以内 新手友好度 88/100
CrimsonCrossBunker/Cataclysm-Cleanwater-Bomb#1167 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
meshcore-dev/MeshCore#3760 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
deepseek-ai/DeepGEMM-Ascend#29 ·
维护者通常 1 天内回复
-
area:lattice bug
难度 1/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复