Post

Replies

Boosts

Views

Activity

Reply to getattrlistbulk returns [ERANGE] (34) when supplied a 16K buffer; does that make sense?
I just had a customer reporting the same issue with getattrlistbulk and ERANGE: Result too large. According to them, it happens on macOS 10.13 with APFS but doesn't happen on macOS 10.14 anymore. I can also confirm that it only happens when the last call exactly fills the buffer. Running FileManager.contentsOfDirectory(atPath:) returns the cumulative amount of entries processed with getattrlistbulk and throws no error.
Jan ’24
Reply to Making filecopy faster by changing block size
Why do you say preferred 1KB, when in the same sentence you say the preferred block size is 1MB? Sorry, my mistake. Let me give you some actual results: when using the "preferred" 1_048_576 block size (returned by URLResourceKey.preferredIOBlockSizeKey) it takes about 6.15 seconds to copy a 7 GB file from my Mac to another folder on the same Mac. When using 16_777_216 block size, I get about 3 seconds instead. If I don't set the block size option for filecopy, I get about the same time as with the preferred block size, so I guess it's probably the same value. My question is: what makes the 1_048_576 block size "preferred", since using 16_777_216 drastically increases the filecopy performance? And can we assume that increasing the block size will always give better performance for filecopy?
Jan ’24
Reply to Making filecopy faster by changing block size
Thanks a lot for your valuable input! Things will go better if your block size matches the allocation block size of the underlying volume When you say "match", do you mean equal, or a multiple, or something else? I'm asking because the value returned by URLResourceKey.preferredIOBlockSizeKey for my Macintosh HD is 1048576, but significantly increasing the block size of filecopy from the "preferred" 1KB to 1MB or higher usually performs better.
Jan ’24
Reply to Xcode warning for call to DispatchQueue.main.sync: Call to method 'asd' in closure requires explicit use of 'self' to make capture semantics explicit
It’s probably worth filing a bug about that. Please post your bug number, just for the record. I created FB13454498. First, I recommend against using Dispatch global concurrent queues, as explained in Avoid Dispatch Global Concurrent Queues. Thank you. While the second WWDC link on the linked page correctly leads to a video, the first link (WWDC 2015 Session 718 Building Responsive and Efficient Apps with GCD) leads to a list of videos where that video cannot be found. Does it still exist? Second, synchronously dispatching to the main queue is a concern because it can block the current thread for long periods of time. I know, but that thread needs access to a resource possibly occupied by the main thread before being able to continue with its work. I think you’d be much better off investing in Swift concurrency. I'm still supporting macOS 10.13, while Swift concurrency is only available on macOS 10.15.
Dec ’23
Reply to Xcode warning for call to DispatchQueue.main.sync: Call to method 'asd' in closure requires explicit use of 'self' to make capture semantics explicit
I forgot to mention that I'm doing this from a background thread: DispatchQueue.global().async { DispatchQueue.main.async { [self] in asd() // no warning or error } DispatchQueue.main.sync { [self] in asd() // warning: Call to method 'asd' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in Swift 6 } }
Dec ’23
Reply to Xcode downloads client crash reports for string interpolation (_StringGuts.append)
You could test this. I manually caused an infinite recursion at the same location as the other crash report and I got a crash report with 511 frames. Frames numbered 9 to 510 are all the same, and since 510 is the last one, it looks like it's cut off. Otherwise the frames look very similar to the crash report downloaded by Xcode. Thread 4 Crashed:: Dispatch queue: com.apple.root.user-initiated-qos 0 CoreFoundation 0x1837f5084 __CFStringEncodeByteStream + 76 1 Foundation 0x184901558 -[NSString(NSStringOtherEncodings) getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 260 2 libswiftCore.dylib 0x1931cf194 _NSStringCopyBytes(_:encoding:into:) + 124 3 libswiftCore.dylib 0x1931d67f0 _StringGuts._foreignCopyUTF8(into:) + 80 4 libswiftCore.dylib 0x1931d7bc8 _StringGuts._foreignConvertedToSmall() + 68 5 libswiftCore.dylib 0x1931d7b44 _StringGuts.append(_:) + 1232 6 libswiftCore.dylib 0x19316ba80 String.write<A>(to:) + 56 7 libswiftCore.dylib 0x19300bef0 DefaultStringInterpolation.appendInterpolation<A>(_:) + 72 8 MyApp 0x1000e4538 String.appendingPathComponent(_:) + 924 (PathAdditions.swift:75) 9 MyApp 0x100119138 Snapshot.renameFile(_:to:) + 696 (Snapshot+Modify.swift:135) 10 MyApp 0x10011915c Snapshot.renameFile(_:to:) + 732 (Snapshot+Modify.swift:135) ... 510 MyApp 0x10011915c Snapshot.renameFile(_:to:) + 732 (Snapshot+Modify.swift:135) And it's also the same exception type: Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000170027fd8 Exception Codes: 0x0000000000000002, 0x0000000170027fd8 Termination Reason: Namespace SIGNAL, Code 10 Bus error: 10 Terminating Process: exc handler [66786] VM Region Info: 0x170027fd8 is in 0x170024000-0x170028000; bytes after start: 16344 bytes before end: 39 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL Stack 16ff9c000-170024000 [ 544K] rw-/rwx SM=PRV thread 3 ---> STACK GUARD 170024000-170028000 [ 16K] ---/rwx SM=NUL ... for thread 4 Stack 170028000-1700b0000 [ 544K] rw-/rwx SM=PRV thread 4 I guess we solved the mystery? Probably the backtrace got cut off along the way between the user and my Xcode instance. Thank you very much for your help!
Nov ’23
Reply to Xcode downloads client crash reports for string interpolation (_StringGuts.append)
Thank you very much for your insights. How did thread 1 get started? You're right, I didn't notice that the stacktrace looks strange. The code in thread 1 is called from inside NSFileCoordinator.coordinate(readingItemAt:options:writingItemAt:options:error:byAccessor:), which in turn is called inside DispatchQueue.global(qos: .userInitiated).async, with some other of my code before and after each of these calls. What’s up with the symbolication? I'm not sure I understand why the double line 135 seems unlikely. I can confirm that in this case it's a recursive method call. Could it be that the program somehow went into infinite recursion, explaining why the thread's origin is cut off?
Nov ’23
Reply to macOS keeps showing "[App] would like to access data from other apps" warning even if accepting it each time
The privilege to access other apps containers falls into that third group. Thanks for confirming. Personally, I think it's quite annoying that it gets shown each time, and the reason why I noticed this in the first place was that users of my app where asking me why the alert is shown each time they scan the disk, given that one is used to seeing this kind of alert only once. I have filed FB13410100 in case you're interested.
Nov ’23
Reply to macOS keeps showing "[App] would like to access data from other apps" warning even if accepting it each time
How is your app signed? A problem with the signature might prevent the OS from "remembering" that permission has been granted before. Thanks for the suggestion, but I don't think there's any problem with the signature. All other warnings (Calendar, Reminders, etc.) only get shown once, but this one gets shown each time. I think it only started appearing since macOS 14 Sonoma.
Nov ’23