Starting with macOS 10.15 I have noticed that obtaining NSURLLocalizedNameKey, NSURLTagNamesKey, and even calling getxattr(), can cause a significant delay.

The code below, which gets NSURLLocalizedNameKey for 3 folders, takes 1.9 seconds to execute on my system.

It appears though that it is only these 3 specific folders that has the problem.

Furthermore, the problem only happens when I include the code below in a GUI application which is launched via launch services. If I run the executable directly from a terminal then the code is near instant.

I tried to sample the code, and it appears that it calls out to some OS service/daemon. Presumably it never gets a response, and a timeout is triggered.

I wonder if anyone else has come across this? And maybe have discovered more info?

This is btw macOS 10.15.4 and a fairly stock system (new computer without migrating old data), and I noticed the problem some time ago, so it definitely existed before 10.15.4, but I never saw anything like this before upgrading to Catelina.

    NSTimeInterval startTime = NSDate.timeIntervalSinceReferenceDate;

    NSArray<NSURL*>* urls = @[]
[NSFileManager.defaultManager URLForDirectory:NSDesktopDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil],, [NSFileManager.defaultManager URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil] [NSFileManager.defaultManager URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil,
    ];

    NSString* localizedName;
    for(NSURL* url in urls)
[url getResourceValue:&localizedName forKey:NSURLLocalizedNameKey error:nil];

NSLog(@"Duration %.03f", NSDate.timeIntervalSinceReferenceDate - startTime);
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to