Post

Replies

Boosts

Views

Activity

Reply to Finder shows warning "Apple could not verify file is free of malware" when setting my app as "Always open with"
[quote='852565022, Etresoft, /thread/795994?answerId=852565022#852565022, /profile/Etresoft'] it would have shown up in the top-level list, not in "Other" [/quote] I didn't say that. The app does show up in the top-level list, as I mentioned: "When choosing my app in the "File > Open With" menu, the file opens just fine in my app". And, by extension, you wouldn't be getting that malware warning either. Unless it's a macOS issue as confirmed by a macOS engineer.
Topic: App & System Services SubTopic: General Tags:
Aug ’25
Reply to Finder shows warning "Apple could not verify file is free of malware" when setting my app as "Always open with"
The issue is that, when I try to reproduce this on a VM, it doesn’t happen. I tried using a VM (I haven't done so in a very long time), but when trying to download Xcode in it, the App Store kept telling me that my password was wrong, so I couldn't get further. While this is annoying, it isn't at all surprising to me: I wanted to transition from using separate partitions for each old macOS version (to test my apps) to using VMs instead, but quickly noticed that a VM may not reproduce all issues found on a "real" macOS installation, and vice-versa. So up to this day I create a new separate partition on an external drive for each new major macOS version. While installing a new partition blocks you from using your Mac for some time, in my opinion it's worth having separate partitions to test things on, since in my experience a VM is not nearly as accurate as the real thing. In alternative, could creating a new user be an alternative for you? I just remembered that Apple Care always asks to test things with a different user.
Topic: App & System Services SubTopic: General Tags:
Aug ’25
Reply to Finder shows warning "Apple could not verify file is free of malware" when setting my app as "Always open with"
[quote='852648022, Etresoft, /thread/795994?answerId=852648022#852648022, /profile/Etresoft'] You were relaying what the end user told you [/quote] I stated the opposite: "This is what happens for me". I only wrote that the user brought the issue to my attention. Never use the App Store. That sounds like a very generic statement and I don't see a reason why not. Would you like to elaborate?
Topic: App & System Services SubTopic: General Tags:
Aug ’25
Reply to Crash when assigning NSImage to `@objc dynamic var` property
Thanks. So it sounds like the NSImage is getting over-released or being incorrectly deallocated, although it's unclear to me what exactly is trying to form a weak reference, since my code (as shown above) has a strong reference. Unfortunately the higher up function calls are made by AppKit, which is not open source, so I cannot look it up. As far as I understand, the link you posted helps investigating memory issues in Xcode, but since the crash reports are downloaded by Xcode from other users and I cannot reproduce it myself... The Xcode statistics seem to show that it only happens with macOS 15.3 or newer. I don't know if it's because there's not enough space to show older releases, or if it's really a clue that it's a change introduced with macOS 15.3 that causes this issue. From my perspective it would make sense that it's a new issue with macOS 15.3, because I haven't changed the code that generates or assigns that image in a very long time, and this issue didn't happen for a previous version of my app that was live on the App Store for 6 months (starting from about one year ago) and had barely any crashes (all unrelated to this one). Perhaps it helps to share how the image is created. The result of the method below is directly assigned to myEntity.image in the code I posted originally. Could any of the used APIs have a bug that causes the image to be released incorrectly? private func image(url: URL?) -> NSImage { if let url = url { let imageURL: URL if let volumeURL = (try? url.resourceValues(forKeys: [.volumeURLKey]))?.volume, volumeURL.path != "/" { imageURL = volumeURL } else { imageURL = url } return (try? imageURL.resourceValues(forKeys: [.effectiveIconKey]))?.effectiveIcon as? NSImage ?? NSImage(named: NSImage.folderName)! } else { return NSImage(systemSymbolName: "questionmark.diamond.fill", accessibilityDescription: nil)!.withSymbolConfiguration(.init(paletteColors: [NSColor(white: 0.95, alpha: 1), .systemPurple]))! } }
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25
Reply to Crash when assigning NSImage to `@objc dynamic var` property
I don't understand. Aren't all these tools you mention (Zombies instrument, ASan, Main Thread Checker etc.) meant to be run in Xcode or Instruments? Or are you saying I should enable some compiler flag in my production build? The thing that makes over-release issues (and most other memory crashes ) hard to debug is that the crash log you’re looking at is NOT why your app crashed. I'm not sure I understand. Is it correct that the line in the crash log myEntity.image = newImage is trying to retain an image that was over-released or is being deallocated, but the thing that over-released it is possibly somewhere else? What thread is myEntity.image accessed on? I mentioned in my original post that it's called on the main thread, and I just checked again and can confirm it. Just to be sure, I'll put a if !Thread.isMainThread { preconditionFailure() } in the next app update, so there won't be a shadow of a doubt anymore. Though it will take a couple weeks before the update is published and the first crash reports will start coming in again. This brings me to: Seeing that code wouldn't actually help. Even not if we assume that it all happens on the main thread? Could there be something else wrong with my code, or could this be a bug in how these images are created by Foundation / AppKit?
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25
Reply to NSTextView.shouldDrawInsertionPoint doesn't work with TextKit 2
[quote='853568022, gnuoyd, /thread/779461?answerId=853568022#853568022, /profile/gnuoyd'] My custom cursor replaces the AppKit default cursor in every instance on Ventura. [/quote] Previously you said that it didn't work consistently. So does it work now? Since you're using TextKit 1 (by explicitly accessing layoutManager), that's expected: I managed to make it work with TextKit 1 as well, but was asking about TextKit 2, where it doesn't work.
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25
Reply to Crash when assigning NSImage to `@objc dynamic var` property
they actually CREATE crashes Thanks, that's what I should have known but didn't fully realize until now. I just tried enabling the Address and Thread Sanitizer (the Main Thread Checker is already enabled), but couldn't reproduce the crash. I'll keep them enabled in the hope that they will create a crash at some point. whatever is going on doesn't involve some simple code flow I could understand that this crash could be caused by multiple threads releasing the image at the same time, but if only the main thread is accessing them, I cannot imagine how they could be over-released. I'm not doing any manual memory management with them or their parent object. If you have any example of how over-releasing could happen without thread contention and manual memory management, I'd be eager to hear it. Otherwise I'll let you know as soon as I'm able to reproduce the crash.
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25
Reply to Finder shows warning "Apple could not verify file is free of malware" when setting my app as "Always open with"
[quote='853647022, kthchew, /thread/795994?answerId=853647022#853647022, /profile/kthchew'] Also, not sure if the original poster's app is sandboxed, but if your app is sandboxed then it looks like the situation is potentially worse: [/quote] My app is sandboxed, and I'm not sure if I ever saw the wording you encountered. But that it indeed worse. In either case, the default action is to move the file to the bin. You're absolutely right (and I failed to point out) that these alerts make the user think that something's wrong or suspicious with the app, and possibly uninstall it. Personally, since the file can be opened once with "File > Open With", I don't see a reason why opening it permanently with "File > Open With > Other" would need such a scary alert.
Topic: App & System Services SubTopic: General Tags:
Aug ’25
Reply to Crash when assigning NSImage to `@objc dynamic var` property
When any image view is being destroyed, make sure you're setting the target image to null and you've torn down any KVO "infrastructure" you've created that's tied to that object The NSImageView is in fact in a NSTableView, and I call NSImageView.bind(_:to:withKeyPath:options:) in the callback passed to NSObject.observe(_:options:changeHandler). The observer is added when the table cell view's objectValue is set, then removed again when it is set to nil. I'll add a call to NSImageView.unbind(.value) and see if that solves the crash. class MyCellView: NSTableCellView { private var observer: NSKeyValueObservation? override var objectValue: Any? { didSet { if let objectValue = objectValue as? MyObject { observer = objectValue.observe(\.property) { [weak self] _, _ in for view in subviews { view.removeFromSuperview() } let imageView = NSImageView(image: nil) imageView.bind(.value, to: objectValue, withKeyPath: keyPath) addSubview(imageView) } } else { observer = nil } } } } That's generally a reasonable statement for the "core" of Objective-C’s memory management model Not sure if it's relevant, but I'm using Swift, although I suspect KVO is at the Objective C level. I would also try Zombies Sorry, forgot to add that I also enabled that one, but no crash for now. I'll keep that enabled too. Thanks for your precious input and I'll update you when I find out more.
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25
Reply to Crash when assigning NSImage to `@objc dynamic var` property
[quote='853904022, DTS Engineer, /thread/777545?answerId=853904022#853904022'] Your code has me a bit confused. [/quote] I should have gone more into details. The property in objectValue.observe(\.property) is actually an array of objects that represent a file URL, and in the observer callback I iterate through that array, create an image view for each element, and bind the image to a property of the respective element. The table view cell effectively displays a dynamic set of URL icons. I modify MyObject.property (I should have called it MyObject.entities) whenever an element is added or removed, and I modify MyEntity.image whenever the image changes. objectValue is set by the table view. I'll think if I can avoid using KVO, but this means I'll have to reload the table view cells manually in quite some places.
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’25