-
Notifications
You must be signed in to change notification settings - Fork 1
Fix Android support #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
@_implementationOnly import COpenCombineHelpers | ||
#endif | ||
|
||
#if os(WASI) | ||
#if os(WASI) || os(Android) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback for generating combine identifiers on Android is non-atomic and not thread-safe, which may produce duplicate IDs under concurrent use. Consider using an atomic counter or lock to ensure uniqueness. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
private var __identifier: UInt64 = 0 | ||
|
||
internal func __nextCombineIdentifier() -> UInt64 { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,7 +9,7 @@ | |||||||||
@_implementationOnly import COpenCombineHelpers | ||||||||||
#endif | ||||||||||
|
||||||||||
#if os(WASI) | ||||||||||
#if os(WASI) || os(Android) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stubbing out the lock on Android removes all mutual exclusion, which can lead to data races in multithreaded contexts. Consider providing a real lock implementation or documenting that this platform build is not thread-safe.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will only be used on main thread in any case. |
||||||||||
internal struct __UnfairLock { // swiftlint:disable:this type_name | ||||||||||
internal static func allocate() -> UnfairLock { return .init() } | ||||||||||
internal func lock() {} | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for this change. Could you elaborate on why this change is necessary?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some CPP interop issue with Android when not using the default setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemancda Thank you for the explanation. However, I don't think relying on default settings is a good approach as it may introduce maintenance burden for future upgrades and it also breaks other platform's build currently (See the failure CI - https://github.com/OpenSwiftUIProject/OpenCombine/actions/runs/15523371994/job/44321270577?pr=22).
Here are my suggestions:
Relying on implicit defaults makes the build configuration less predictable and harder to maintain across Swift toolchain versions. Let's work together to find a solution that uses explicit settings while maintaining Android compatibility.