notify icon indicating copy to clipboard operation
notify copied to clipboard

Use `objc2-core-foundation` and `objc2-core-services`

Open madsmtm opened this issue 1 month ago • 9 comments

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.

madsmtm avatar Oct 28 '25 14:10 madsmtm

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.

riberk avatar Oct 28 '25 16:10 riberk

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.

madsmtm avatar Oct 30 '25 14:10 madsmtm

I like it. But I don't have a mac to test it.

dfaust avatar Oct 30 '25 18:10 dfaust

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 avatar Oct 31 '25 11:10 riberk

@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.

dfaust avatar Oct 31 '25 13:10 dfaust

@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.

riberk avatar Oct 31 '25 13:10 riberk

The tests added in main now, could you rebase and ensure if something isn't broken? @madsmtm

JohnTitor avatar Nov 05 '25 21:11 JohnTitor

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.

madsmtm avatar Nov 06 '25 20:11 madsmtm

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.

JohnTitor avatar Nov 07 '25 02:11 JohnTitor