Document main actor execution requirements in Java-hosted processes
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- documentation
Hướng nghiên cứu
Tìm tài liệu về các API bất đồng bộ của Swift và các tiến trình do Java lưu trữ. Vì issue không nêu tên tệp cụ thể, trước tiên hãy xác định điểm bắt đầu phù hợp trong tài liệu. Giải thích rằng các lệnh gọi phụ thuộc vào trình thực thi chính của Swift có thể ngừng tiến triển tùy thuộc vào môi trường máy chủ, và có thể cần tích hợp ở phía máy chủ. Hoàn tất khi người dùng có thể tìm thấy hạn chế này và hiểu lý do nó xảy ra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
swift-java can export asynchronous Swift functions annotated with @MainActor to Java. However, depending on the host environment, a call may stop making progress when it switches to the main actor. This can happen not only when the exported function is itself annotated with @MainActor, but also when a Swift library uses the main actor internally.
It is natural for swift-java users to expect @MainActor, a standard Swift language feature, to work as usual. As a result, they may not immediately recognize the cause of the problem. The issue is also technically complex, making it difficult for many users to address.
For an example, see:
Technical background
This problem occurs when work submitted to Swift's main executor is not executed in the host environment.
When a Swift executable is launched, its entry point and platform environment are responsible for running asynchronous work and event loops. In contrast, when a Java application calls Swift, the Java host manages the process entry point and event loop. swift-java generates bindings for Swift libraries used in that process. Depending on the host environment, additional integration may therefore be needed to run Swift's main executor.
For example, swift-android-native provides an implementation that uses the private libdispatch API _dispatch_main_queue_callback_4CF to process the Dispatch main queue used by Swift's main executor on the Android main looper.
Proposal
Ideally, users should be able to use Swift code that relies on @MainActor without additional effort. However, swift-java does not own the host process's entry point or event loop, and the necessary integration depends on the host environment and application configuration.
As a first step, I propose updating the documentation so that users can discover this limitation and understand that host-side integration may be needed. I am preparing a PR for the documentation update.
Future directions
In the future, it may be worth considering whether swift-java should provide an implementation to run the main executor. For example, one possibility would be to start a dedicated thread at JNI_OnLoad to drive the Swift main executor.
- Ngôn ngữ chính
- Swift
- Star
- 1.3k
- Fork
- 127
- Merge trung bình
- 1 giờ 6 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swiftlang/swift-java
-
wrap-java: Optional convenience methods can fail to compile when a parameter shadows the method nameĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
swiftlang/swift-java#945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
swiftlang/swift-java#663 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
swiftlang/swift-java#949 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
swiftlang/swift-java#948 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
swiftlang/swift-java#947 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của swiftlang/swift-java
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
JWhite212/SignalLadder#215 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Notch: show the playing trackĐang mởenhancement mac
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100