Explore the core architecture of the operating system, including the kernel, memory management, and process scheduling.

Post

Replies

Boosts

Views

Activity

obtaining file creation & modified time & size failing 5-10% of time within .onOpenURL when file shared with app
When users share a file with my app I am having trouble 5-10% of the time obtaining the file meta data, specifically creation and modified time and size. Using SwiftUI with the code below.. .onOpenURL { url in var fileSize: Int64 = 0 var creationTime: Date = Date(timeIntervalSince1970: 0) var modificationTime: Date = Date(timeIntervalSince1970: 0) do { let fileAttributes = try FileManager.default.attributesOfItem(atPath: url.path) fileSize = fileAttributes[FileAttributeKey.size] as? Int64 ?? 0 creationTime = fileAttributes[FileAttributeKey.creationDate] as? Date ?? Date(timeIntervalSince1970: 0) modificationTime = fileAttributes[FileAttributeKey.modificationDate] as? Date ?? Date(timeIntervalSince1970: 0) <SNIPPED CODE no other tries though and not involving above variables> } catch { // quite confident I am ending up here because variables after the above code aren’t being set and there are no other try blocks, // so FileManager.default.attributesOfItem(atPath: url.path) must be throwing…. } <SNIPPED CODE> To attempt to resolve this, I added in a 0.5 second wait cycle if creationTime == 0 and modificationTime == 0 , so if obtaining both metadata fails, wait 0.5 seconds and try again, try this a max of 3 times and then give up. I don’t know how often I am entering this code (didn’t instrument the app for it), but am still getting times when metadata comes back blank which means this code wasn’t successful after 3 tries. I assume the file would only become visible and sharable with my app after it has completed being written by the original app/process. Perhaps it hasn’t finalized yet? Is there a way to detect this so I can tell the user in my share screen to wait and try again? I am assuming that the file has finished writing though since when I read the data from the file contents, it’s good data and complete even when metadata failed. I will be instrumenting the above code in my next app version, just hoping to fix it right now since users are emailing saying my app is broken. Thanks!
3
0
395
Sep ’24
com.apple.root.default-qos EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020
Crashed: com.apple.root.default-qos 0 libobjc.A.dylib 0x275c objc_release + 16 1 libobjc.A.dylib 0x275c objc_release_x0 + 16 2 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 3 libobjc.A.dylib 0x4f00 objc_destructInstance + 80 4 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80 5 CoreServices 0x47f0 std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::__deallocate_node(std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, void*>>) + 36 6 CoreServices 0x47ac std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::~__hash_table() + 28 7 CoreServices 0x4760 -[LSRecord dealloc] + 36 8 CoreServices 0x472c -[LSBundleRecord dealloc] + 72 9 CoreServices 0x1bb7c -[LSApplicationProxy .cxx_destruct] + 60 10 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116 11 libobjc.A.dylib 0x4f00 objc_destructInstance + 80 12 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80 13 CoreServices 0xb42d4 +[LSBundleProxy clearBundleProxyForCurrentProcess] + 48 14 CoreServices 0xb436c __45+[LSBundleProxy bundleProxyForCurrentProcess]_block_invoke.21 + 36 15 libdispatch.dylib 0x3dd4 _dispatch_client_callout + 20 16 libdispatch.dylib 0x72d8 _dispatch_continuation_pop + 600 17 libdispatch.dylib 0x1b1c8 _dispatch_source_latch_and_call + 420 18 libdispatch.dylib 0x19d8c _dispatch_source_invoke + 832 19 libdispatch.dylib 0x6dc4 _dispatch_queue_override_invoke + 504 20 libdispatch.dylib 0x15894 _dispatch_root_queue_drain + 392 21 libdispatch.dylib 0x1609c _dispatch_worker_thread2 + 156 22 libsystem_pthread.dylib 0x48f8 _pthread_wqthread + 228 23 libsystem_pthread.dylib 0x10cc start_wqthread + 8
1
0
166
Sep ’24
Callkit blocking behaviour is overridden in iOS 18
In iOS 18 if a number is registered with CallKit to be blocked, then if that number is also in contacts, then the number isn't blocked. If a user has added a number to their contacts, then in all probability they might not want the number blocked, so this might seem reasonable behaviour. However the point is, this is new behaviour for CallKit in iOS 18, and its never been like this before going back several years to the very first release. Why suddenly change it now, after all these years, without notice nor documentation, and take away that option from the user, should for some reason, they want to block a number which is also in their contacts. This is quite a disruptive change for apps using CallKit.
8
0
720
Sep ’24
handling files offloaded to iCloud?
My app saves its document files by default into ~/Documents. It does some important domain-specific stuff when a document is deleted. I monitor for deletion using https://github.com/eonist/FileWatcher Unfortunately several users have noticed my app doing this cleanup work even when they have not deleted the corresponding document. We've traced it through and realised it's the iCloud "Optimise Mac Storage" feature, or "Store in iCloud &gt; Desktop and Documents". I'm not sure which because I don't use these features of macOS at all, and also they seem to have been renamed or changed in Sonoma. Either way, I'm wondering: a) how I can tell in Swift whether a file has actually been deleted, or whether it's been "offloaded" to iCloud by macOS. b) how can I test this? My research is pointing at urlubiquitousitemdownloadingstatus but it's hard to play with it without knowing how to test it.
2
0
374
Sep ’24
iOS Date & Time Settings
Hi, I’m an app developer and I would like to suggest that there is an API that allows me to check if the user has set their date and time setting to automatic. That setting should be accessible as a read only value. This would allow several apps to operate offline as there is no longer a need to check the internet for an accurate time to prevent users from skipping time ahead. I have implemented this check on my app on Android and it has been very well received as it is able to operate offline again. It would be a huge plus to be able to make my app offline compatible again.
2
0
285
Sep ’24
How can I read a dataless file from within the same or another FileProvider extension?
How can I read a dataless file from within the same or another FileProvider extension? When I pass the visible URL to AVAsset from AVFoundation, it throws the following error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x15b01b1e0 {Error Domain=NSPOSIXErrorDomain Code=11 "Resource deadlock avoided"}, NSLocalizedFailureReason=An unknown error occurred (11), AVErrorFailedDependenciesKey=( "assetProperty_Tracks" ), NSURL=file:///Users/<<username>>/Library/CloudStorage/<<file-path>>, NSLocalizedDescription=The operation could not be completed} The code snippet works fine if executed as a separate Swift process. I'm using AVAsset with AVAssetExportSession to export a subset of the file being read. So I can't use NSFileProviderManager.requestDownloadForItem(withIdentifier:, requestedRange:) because I don't know the offset range required by the AVFoundation library.
1
0
371
Sep ’24
JavaScriptCore Crashed on iOS17 and above systems
After the release of iOS17, our app has collected JavaScriptCore crashes, and the crash has recently appeared in iOS17 and above. The number of crashes collected recently is increasing. We have tried various methods to troubleshoot and locate。 2024-05-08_20-45-00.5216_+0800-fdb980f66f56d73b944ccc3466922d7fd0690089.crash 2024-05-09_12-35-57.5470_+0800-70e61e8796f6967e04d1f523c54dde7b19dea31c.crash T 2024-05-13_14-30-03.2084_+0800-d9598b08a153f5214b51257400423d4079049578.crash he crash stack is as follows:
1
0
299
Sep ’24
[iOS 18] Initializing CBCentralManager doesn't trigger prompting Bluetooth permission sometimes
The issue While testing how our app behaves on iOS 18 beta 6, we found an issue on one of our iPhones: At some point, the app creates CBCentralManager in order to trigger an alert to request Bluetooth permission; The alert is not shown; centralManagerDidUpdateState never gets called, the state is always .unknown. Below is a sample code I used to reproduce it easier: class ViewController: UIViewController, CBCentralManagerDelegate { var centralManager: CBCentralManager? @IBOutlet weak var stateLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() print("Test app ready") } @IBAction func onPressedRequestPermission(_ sender: Any) { self.stateLabel.text = "Requested BLE permission" centralManager = CBCentralManager(delegate: self, queue: nil) } func centralManagerDidUpdateState(_ central: CBCentralManager) { var stateString = "" switch central.state { case .poweredOn: stateString = "poweredOn" case .unknown: stateString = "unknown" case .resetting: stateString = "resetting" case .unsupported: stateString = "unsupported" case .unauthorized: stateString = "unauthorized" case .poweredOff: stateString = "poweredOff" @unknown default: stateString = "unknownDefault" } print("CBCentralState changed: \(stateString)") self.stateLabel.text = "CBCentralState: \(stateString)" } } I ran this code on two devices - one with the issue and one without it, and compared the logs from Console. I noticed that the last similar logs were 15:44:25.428118+0200 tccd AUTHREQ_PROMPTING: msgID=8163.2, service=kTCCServiceBluetoothAlways, subject=Sub:{... After that, the bug-free device printed this within the next ~250ms: 15:44:25.432285+0200 SpringBoard Asked to bootstrap a new process for handle: [osservice<com.apple.tccd>:8144] ... 15:44:25.675380+0200 SpringBoard Received request to activate alertItem: <SBUserNotificationAlert: 0xc4289cf00; title: Allow “test1” to find Bluetooth devices?; source: tccd; pid: 8144> and showed the request for Bluetooth permission. At the same time, there were no such logs on the problematic device, and the request was not displayed. Other apps behavior nRF Connect app cannot request Bluetooth permission too on the same device. Usually it does that immediately after the first launch, but this time we saw only an error "Your device reports an unknown error for Bluetooth use." and no BT request alert. The question How can we programmatically detect that there is some unknown issue with Bluetooth in a similar way how nRF Connect does that?
4
0
514
Sep ’24
Validate user credentials and impersonate user
Working on a file server in c/c++ and need to do following: Validate user credentials (mac Username & password) Impersonate user security context in a thread running in a daemon, so that I can enumerate user's home directory and files/folders. Regarding 2, found API: pthread_setugid_np - is this the right approach? If so, how do I verify user credentials and call this API? Found this section in TN2083: Does this mean that its really not possible to impersonate user and access their home directory etc if the user isn't logged in via terminal/console? or if they have FileVault enabled?
6
0
382
Sep ’24
iOS 18 CoreBluetooth Unable to Discover Primary Services and Characteristics
Hi, after updating to iOS 18 beta 6, I’ve been experiencing unexpected behavior with CoreBluetooth when trying to discover primary services and characteristics of Bluetooth devices. This issue wasn’t present in previous iOS versions, such as iOS 17, where the same code and setup worked flawlessly. Issue Details: iOS 17: The primary services and characteristics are discovered without any issues. iOS 18 Beta 6: Primary services and characteristics are not being discovered at all, leading to incomplete or failed Bluetooth communication. Troubleshooting Steps Taken: Verified Bluetooth permissions and settings in the app. Tested the same codebase on devices running iOS 17 and iOS 18 beta 6. Used nRF Connect to compare service Has anyone else experienced this issue? discovery results between different iOS versions.
2
1
352
Sep ’24
How can I access the download status of an NSFileProviderItem from the File Provider extension?
When capturing materialized information from materializedItemsDidChange in NSFileProviderReplicatedExtension, the isDownloaded property of NSFileProviderItem is not set during the call to enumerate items (NSFileProviderEnumerationObserver:enumerateItems(for:startingAt:)). Both the IsDownloaded and isMostRecentVersionDownloaded properties are returning false, even though the item is fully materialized How to capture this information from file provider extension ? Any help would be greatly appreciated. Thanks!
2
0
401
Sep ’24
Startup Items Cache Issue: New Items from the Same Team Fail
Our team has two products. The first product adds two /Library/LaunchDaemon startup items and one /Library/LaunchAgents startup item, which run normally after installation. A few months later, our team developed another product, which adds two /Library/LaunchDaemon startup items and one /Library/LaunchAgents startup item. However, we found that on some customers' systems, these startup items for the second product do not load correctly, and the processes do not start. Restarting the system does not resolve the issue. This occurs across systems running versions 14.5 to 14.6.1. The app's signatures, notarization, and Gatekeeper validations all pass. Eventually, we discovered that by disabling and then re-enabling our team's startup items in the System Settings - Login Items, all the startup items from our team load correctly. Could this be a caching bug related to new startup items from the same team?
2
0
284
Sep ’24
macOS mmap / dlopen problem
We are having a problem in our C++ app with dlopen returning memory addresses which were previous reserved using mmap() with the MAP_ANON | MAP_PRIVATE | MAP_JIT flags. The mmap is memory is 4Kb page-aligned and returns normally, however sometime later dlopen() is returning an address within the mmap range when no munmap() has been performed. This looks like a bug in the macOS kernal memory manager. Back in July, I opened support ticket FB14442215 where one of our Engineers was able to create a similar and reproducible problem using Preview to load a large bitmap. This ticket has not yet been acted upon, still showing a status of "Open" . Any help or suggestions would be most welcome. Norm Green norm(dot)green(at)gemtalksystems(dot)com
1
0
335
Sep ’24