Skip to content

fix(file-provider): Build XPC components with ARC - #11081

Open
claucambra wants to merge 7 commits into
masterfrom
work/xpc-arc
Open

claucambra wants to merge 7 commits into
masterfrom
work/xpc-arc

Conversation

@claucambra

Copy link
Copy Markdown
Collaborator

Summary

Adds remaining XPC components to ARC build

Checklist

AI (if applicable)

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra claucambra added this to the 35.0.1 milestone Oct 15, 2026
@claucambra claucambra self-assigned this Oct 15, 2026
@claucambra claucambra added os: 🍎 macOS Apple macOS, formerly also known as OS X feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. labels Oct 15, 2026
@claucambra

Copy link
Copy Markdown
Collaborator Author

/backport to stable-35.0

@claucambra
claucambra added this pull request to stack #11084 October 16, 2026 10:05
…abled

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>

@i2h3 i2h3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait… No, actually, this does not compile. 😅 It looks good but there is a problem with it.

Must fix

  1. The branch does not compile (src/gui/macOS/fileproviderxpc_mac_utils.mm:93, :139)

    • What this is: getFileProviderServices and connectToFileProviderServices wait on a dispatch group and then free it.
    • Problem: These two dispatch_release(group) calls were missed in the ARC conversion. Under -fobjc-arc, clang fails with 'release' is unavailable: not available in automatic reference counting mode.
    • Fix: Delete both lines, as was already done in getDomainManagers and getFileProviderDomainIdentifier.
    • If we skip it: Every build with BUILD_FILE_PROVIDER_MODULE=ON fails, and so does this commit when bisecting.
  2. FileProviderXPCUtilsTest no longer compiles, and its ownership checks are now wrong (test/macOS/testfileproviderxpcutils.cpp, src/gui/macOS/fileproviderxpc_mac_utils.h:19)

    • What this is: The test checks who owns the objects that the XPC utilities return. It is built with -x objective-c++ and without -fobjc-arc (test/macOS/CMakeLists.txt:14).
    • Problem: The header now contains static_assert(__has_feature(objc_arc)), so the test fails to compile. Even without the assert, the test still calls release on values that ARC now returns at +0 ([services release] at lines 203 and 215, [domainIdentifier release] at line 228). That over-releases them and crashes.
    • Fix:
      • Compile the test with -fobjc-arc next to -x objective-c++.
      • Remove the manual release calls, and take the returned pointers back with __bridge_transfer.
      • Wrap the processClientCommunicationConnections calls in @autoreleasepool { } before the *Deallocated checks.
      • Drop or rename clientCommunicationDomainIdentifierCanBeReleasedByCaller, because the +1 contract it tests no longer exists.
      • Move the static_assert from the header into fileproviderxpc_mac_utils.mm and fileproviderxpc_mac.mm, as every other ARC file does (e.g. src/gui/macOS/fileprovider_mac.mm:18).
    • If we skip it: CI fails when tests are built, and nothing tests the new ownership contract.

Should fix

  1. AGENTS.md now says every Objective-C file uses ARC, but 8 files still do not (AGENTS.md:218)
    • What this is: This rule tells agents which memory-management model to follow.
    • Problem: These files still use manual reference counting: src/gui/cocoainitializer_mac.mm, src/gui/macOS/fileproviderservice.mm, src/gui/macOS/findersyncservice.mm, src/gui/macOS/findersyncxpc_mac.mm, src/gui/macOS/localnetworkpermission.mm, src/gui/updater/sparkleupdater_mac.mm, src/libsync/settingsources_mac.mm and src/libsync/theme_mac.mm. The old warning against ARC-only features in those files is gone. An agent that edits findersyncxpc_mac.mm and follows the new rule leaves out release, so the object leaks without any warning. Or the agent converts the whole file as an unrelated side change.
    • Fix: Keep the new rule as the goal, and add one sentence: files not yet compiled with -fobjc-arc (see src/gui/CMakeLists.txt and src/common/common.cmake) still use manual reference counting until a separate change converts them.
    • If we skip it: Agents add leaks to the files that still use manual reference counting.

Nice to have

  1. A copy that is no longer needed (src/gui/macOS/fileproviderxpc_mac_utils.mm:203)
    • What this is: getFileProviderDomainIdentifier returns the domain identifier as an NSString.
    • Problem: [[NSString alloc] initWithString:...] only existed to give manual-reference-counting callers a +1 object to release. Under ARC it is an extra copy.
    • Fix: return domainIdentifier.toNSString();
    • If we skip it: Each call makes one small extra copy. Nothing breaks.

Assisted-by: Codex:GPT-6
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Compile the tests with ARC and adopt retained opaque pointers with bridge
transfers. Check object lifetimes after input owners and autorelease pools
drain, and keep ARC assertions in the implementation files.

Assisted-by: Codex:GPT-6
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Require ARC for new Objective-C sources while preserving manual reference
counting in existing files until they are migrated separately.

Assisted-by: Codex:GPT-6
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Assisted-by: Codex:GPT-6
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra

Copy link
Copy Markdown
Collaborator Author

@i2h3 thanks for the comments

Wait… No, actually, this does not compile. 😅 It looks good but there is a problem with it.

looks like I missed what broke when I extracted this from the original xpc timeout branch
thanks, fixed

its ownership checks are now wrong

also fixed

AGENTS.md now says every Objective-C file uses ARC, but 8 files still do not

thanks, fixed

A copy that is no longer needed

also fixed

@claucambra
claucambra requested a review from i2h3 October 19, 2026 16:40
Enable ARC for Cocoa startup, local network permission probes, FinderSync
services and XPC, the File Provider service, and Sparkle.

Keep application startup in a scoped autorelease pool, balance opaque XPC
references, and detach native delegates before their C++ owners disappear.
Add regression coverage for native object lifetime, queued replies,
cancellation, teardown, and late callbacks.

Assisted-by: Codex:GPT-6
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
6 New Code Smells (required ≤ 0)
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-request feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. os: 🍎 macOS Apple macOS, formerly also known as OS X

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants