Use `objc2-core-foundation` and `objc2-core-services`
objc2-core-foundation provides safer and auto-generated wrappers around CoreFoundation than the ones provided by fsevent-sys. In particular, you no longer have to worry about when to call CFRelease, objc2-core-foundation will mostly take care of that for you.
objc2-core-services does the same, but for CoreServices, in particular the FSEvents API that notify uses.
I maintain both crates as part of the objc2 project.
I have tried to keep the functionality as close to the existing as possible, to make this PR easier to review and bisect, though I suspect the code in append_path and remove_path could be simplified.
This is an alternative to updating to fsevent-sys v5.1.0. I have filed a similar PR to fsevent in https://github.com/octplane/fsevent-rust/pull/48.
I'm not a member, but I noticed your suggestion to replace servo core foundation with these crates (the team has accepted the changes, but they haven't been merged yet), and also the wgpu team did the same.
I think it’s worth mentioning, since they have a much larger and more active community, and they might have already investigated these crates.
IMO, it’s a good idea, but personally I’d prefer us to have more tests — especially for corner cases — before applying the update.
IMO, it’s a good idea, but personally I’d prefer us to have more tests — especially for corner cases — before applying the update.
Fair enough, how do you propose we test things like this though? It's kinda hard, since most of it touches the file system and involves multiple processes to test their interaction.
I like it. But I don't have a mac to test it.
Fair enough, how do you propose we test things like this though? It's kinda hard, since most of it touches the file system and involves multiple processes to test their interaction.
OK, I'm going to add tests from the old PR and others, if something else comes to my mind
@riberk You are very welcome to do so. But be careful, these tests used to be extremely flaky. That's why we removed them at some point. In order to be useful we need automatic retries.
@riberk You are very welcome to do so. But be careful, these tests used to be extremely flaky. That's why we removed them at some point. In order to be useful we need automatic retries.
Yeah, I got it. I think I’ll be able to adapt them so they won’t be flaky — I’ll use channels instead of timeouts, ignore the order of events, and so on.
The tests added in main now, could you rebase and ensure if something isn't broken? @madsmtm
cargo test passes on macOS 15.6.1 if that's all you wanted me to test?
I did also try out the examples, they seemed to act the same before and after.
Yeah, thank you! I think the tests added by @riberk would be a great safeguard here.
Basically I'd like to accept this replacement, given the community leans to accept transitions and the benefits from it. I'm going to take a deeper look in a week or so.