I’ve built an app that connects via Bluetooth to a device. The device sends up, down, left and right commands.
I want to build an SDK for other third party developers to use so that whenever a third party app with the SDK opens, if we press a button on the device, my app which captures the button press should be able to forward the event to the third party app.
I want to achieve this with the lowest latency possible so that I can enable a variety of use cases like simple games and interactions within other apps.
What would be the best way for me to achieve this as part of my SDK and my app?
Processes & Concurrency
RSS for tagDiscover how the operating system manages multiple applications and processes simultaneously, ensuring smooth multitasking performance.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
This is a successor to:
https://developer.apple.com/forums/thread/814231
I went into a slightly different direction. I generated more AI slop that use NSLock. Then I had the NSLock usage changed to Mutex usage. Now it crashes with:
Task 13: EXC_BREAKPOINT (code=1, subcode=0x18d29326c)
On one of the mutex closures. With an extended description:
warning: TypeSystemSwiftTypeRef::operator(): had to engage SwiftASTContext fallback for type $s7Combine10PublishersO21LineBreakingPublisherE11SplitAtZeroV12Subscription33_D18F5AAE73662968F407B0A79FBD1F8DLLCy_x_qd__GD
I put the class, a Subscription nested in its corresponding Publisher operator, in the given file
Subscription.txt
macOS 26 "Tahoe" is allocating much more memory for apps than former macOS versions: A customer contacted me with my app's Thumbnail extension allocating so much memory that her 48 GB RAM Mac Mini ran into "out of application memory" state. I couldn't identify any memory leak in my extension's code nor reproduce the issue, but found the main app allocating as much as 5 times the memory compared to running on macOS 15 or lower.
This productive app is explicitly using "Liquid Glass" views as well as implicitly e.g. for an inspector pane. So I created a sample app, just based on Xcode's template of a document-based app, and the issue is still showing (although less dramatically): This sample app allocates 22 MB according to Tahoe's Activity Monitor, while Sequoia only requires 16 MB:
macOS 15.6.1
macOS 26.2
Is anyone experiencing similar issues? I suspect some massive leak in Tahoe's memory management, and just filed a corresponding feedback (FB21967167).
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
Foundation
QuickLook Thumbnailing
AppKit
Hi,
I've now identified a few areas when BGContinuedProcessingTask gets expired by the system
no progress for ~30 seconds
high CPU usage
high temperature
Some of these I can preempt and expire preemptively and handle the notification, others I cannot and just need to let the failure bubble up.
When the failure does bubble up, I'd like to update the title and subtitle. I'm able to update the title, but the subtitle is fixed at "Task Failed"
Is there any workaround? Or shall I file a bug here?
I'm working on an editor for Bevy games and wanted the following workflow:
Launch the game process
Host a Metal view for the game's render target
Use an XPC service to transfer an MTLSharedTextureHandle
Keep the connection for editor/game communication and hot reload
As such I created the following editor service:
public let XPCEditorServiceName = "org.bevy.editor"
public enum XPCEditorMessage: Codable {
case ping
}
public enum XPCEditorReply: Codable {
case pong
}
extension XPCListener {
static let bevy = try! XPCListener(service: XPCEditorServiceName) { request in
request.accept(XPCEditorService.init)
}
}
struct XPCEditorService: XPCPeerHandler {
let session: XPCSession
private func handle(_ message: XPCEditorMessage) -> XPCEditorReply? {
switch message {
case .ping:
return .pong
}
}
func handleIncomingRequest(_ message: XPCReceivedMessage) -> (any Encodable)? {
do {
return handle(try message.decode())
} catch {
return nil
}
}
func handleCancellation(error: XPCRichError) {
print(error)
}
}
and I initialize it in my app's App initializer:
// Launch the XPC service
print(XPCListener.bevy)
I wanted to test this using an executable target with the following main.swift:
let session = try XPCSession(xpcService: XPCEditorServiceName)
let response: XPCEditorReply = try session.sendSync(XPCEditorMessage.ping)
print("Connected to editor!")
The editor prints Listener<org.bevy.editor>(Active) but the game fails with Underlying connection was invalidated. Reason: Connection init failed at lookup with error 3 - No such process
What am I doing wrong?
PS. Would also appreciate an example of sending & rendering the MTLSharedTextureHandle both in editor & game.
I have migrated my code to use SMAppService but am running into trouble deleting the old SMJobBless launchd registration using launchd remove. I am invoking this from a root shell when I detect the daemon and associated plist still exist, then also deleting those files.
The remove seems to work (i.e. no errors returned) but launchd list shows the service is registered, with a status code of 28
I am using the same label for SMAppService as previously and suspect this is the reason for the problem. However, I am reluctant to change the label as there will a lot of code changes to do this.
If I quit my application, disable the background job in System Settings and run sudo launchd remove in the Terminal then it is removed and my application runs as expected once the background job is re-enabled. Alternatively, a reboot seems to get things going.
Any suggestions on to how I could do this more effectively welcome.
Hello,
I am working on a cross-platform application where IPC between a LaunchDaemon and a LaunchAgent is implemented via Unix domain sockets. On macOS, the socket path length is restricted to 104 characters.
What is the Apple-recommended directory for these sockets to ensure the path remains under the limit while allowing a non-sandboxed agent to communicate with a root daemon? Standard paths like $TMPDIR are often too long for this purpose.
Thank you in advance!
Hi,
I’m looking for clarification on what concurrency and consistency guarantees Apple provides when multiple targets (main app + Widget extensions) access shared storage.
Specifically:
1. UserDefaults (App Group / suiteName:)
• If multiple processes (app + multiple widget instances) read and write the same shared UserDefaults, what guarantees are provided?
• Is access serialized internally to prevent corruption?
• Are read–modify–write operations safe across processes, or can lost updates occur?
2. Core Data (shared SQLite store in App Group container)
• Is it officially supported for multiple processes to open and write to the same Core Data SQLite store?
• Are there recommended configurations (e.g. WAL mode) for safe multi-process access?
• Is Apple’s recommendation to have a single writer process?
3. FileManager (shared container files)
• If two processes write to the same file in an App Group container, what guarantees are provided by the system?
• Is atomic replaceItemAt the recommended pattern for safe cross-process updates?
Additionally:
• Do multiple widget instances count as separate processes with respect to these guarantees?
• Is there official guidance on best practices for shared persistence between app and widget extensions?
I want to ensure I’m following the correct architecture and not relying on undefined behavior.
Thanks.
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
Foundation
WidgetKit
Core Data
Concurrency