napi backend: incoming ObjC blocks are bridged without retention — async completion/decision handlers die after the delegate returns

Đang mở
#111 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, objective-c
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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/runtimes 5b697b39, generic napi backend, TARGET_PLATFORM=macos (the same block-marshalling path ships in the iOS napi runtime, where async WKUIDelegate/PHPhotoLibrary-style completions hit the same lifetime gap)
Ngôn ngữ chính
C++
Star
27
Fork
5
Merge trung bình
5 ngày 11 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NativeScript/runtimes

Tất cả issue của NativeScript/runtimes

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.