Open swift-ci opened 5 years ago
This sounds like it's an issue with the Combine framework, which is not part of the Swift open source project, so it's going to be tracked on https://feedbackassistant.apple.com.
Can you submit feedback on that website and attach a sample project that's crashing? That would really help the Combine folks figure out the root cause of your issue. Thanks!
Comment by Ben D. Jones (JIRA)
I'll take a look I'm one of the maintainers of Combine...
Comment by Ben D. Jones (JIRA)
@swift-ci create
Comment by Ben D. Jones (JIRA)
I've filed a radar internally for this... thanks for the report!
Comment by Ben D. Jones (JIRA)
So apologies for this taking a bit to respond to but the following is working for me in Xcode Beta 7 (11M392r)
Here's what I used to test this out.
import UIKit
import Combine
class ViewController: UIViewController {
var subscriptions: [AnyCancellable] = []
let scrollView = UIScrollView()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
view.addSubview(scrollView)
scrollView.frame = view.frame
scrollView.contentSize = CGSize(width: view.frame.width, height: view.frame.height * 2)
scrollView.contentOffsetPublisher.sink {
print("Offset: \($0)")
}
.store(in: &subscriptions)
}
}
extension UIScrollView {
var contentOffsetPublisher: AnyPublisher<CGPoint, Never> {
return self.publisher(for: \.contentOffset)
.eraseToAnyPublisher()
}
}
Running this and scrolling I'm getting the signals in the sink as expected.
Offset: (0.0, -44.0)
Offset: (0.0, -44.0)
Offset: (0.0, -44.0)
Offset: (0.0, -30.0)
Offset: (0.0, -27.5)
Offset: (0.0, -27.5)
Offset: (0.0, -13.0)
Offset: (0.0, 34.0)
Offset: (0.0, 34.0)
Offset: (0.0, 90.5)
Offset: (0.0, 173.0)
Offset: (0.0, 173.0)
Offset: (0.0, 272.5)
Offset: (0.0, 388.0)
Offset: (0.0, 388.0)
Offset: (0.0, 434.0)
This is a simple example but mind re-testing this and letting me know what you see.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | bendjones (JIRA) | |Priority | Medium | md5: 47ec293034be223e8941121bc333f3a8Issue Description:
Hello 🙂,
I am creating a custom Combine publisher by extending UIScrollView, as the following.
However, I just realised that when contentOffsetPublisher is used, the app crashes with the following information.
This is something that I don't expect to happen. However, let me know if I am missing something.
(Fyi, there is no crash when I
debounce
it)Thank you in advance.