Post

Replies

Boosts

Views

Activity

Reply to NSTextView doesn't correctly redraw when deleting text and setting attribute at the same time
For some reason the code above doesn't reproduce the issue anymore. Here is new code that seems to work (for now): class ViewController: NSViewController { @IBOutlet var textView: NSTextView! override func viewDidAppear() { textView.textContainerInset = CGSize(width: 0, height: 8) let _ = textView.layoutManager textView.textStorage!.setAttributedString(NSAttributedString(string: "1\n\n2\n3\n4")) textView.textStorage!.addAttribute(.foregroundColor, value: NSColor.labelColor, range: NSRange(location: 0, length: textView.textStorage!.length)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 0, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 1, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 3, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 5, length: 2)) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [self] in textView.selectedRange = NSRange(location: 3, length: 0) textView.deleteBackward(nil) textView.textStorage!.beginEditing() textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 0, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 2, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 4, length: 2)) textView.textStorage!.addAttribute(.paragraphStyle, value: paragraphStyle(indent: 100), range: NSRange(location: 6, length: 1)) textView.textStorage!.endEditing() } } private func paragraphStyle(indent: Double) -> NSParagraphStyle { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.firstLineHeadIndent = indent return paragraphStyle } }
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’25
Reply to Crash reports downloaded by Xcode contain impossible call hierarchy
Well, the issue is that the crash report makes it look like a certain method is called which cannot be, and if I ignore that particular frame line, then everything is coherent. So if the explanation, as I assumed, is that merged @objc means that the method was not actually part of the call stack, then everything's ok. I just think that it shouldn't be listed there at all, because it's only confusing.
Mar ’25
Reply to Crash reports downloaded by Xcode contain impossible call hierarchy
This seems to be in fact the same issue that was pointed out in https://developer.apple.com/forums/thread/760029 The output of xcrun crashlog /path/to/crash.crash contains [ 4] 0x0000000100bf81b8 MyApp`MyApp.MainViewController.showSettings(Any) -> () + 428 at MainViewController.swift:132:30 [ 5] 0x0000000100ba252f MyApp`merged @objc MyApp.ConfirmMoveViewController.openSourceInFinder(Any) -> () + 79 merged @objc, if I understand correctly, indicates some compiler optimization. So it would seem that on the way to calling the showSettings method some reused part of the openSourceInFinder method is used, but the crash log makes it appear like openSourceInFinder was genuinely called. Could this perhaps be something to be optimized in how macOS creates crash logs, or is there a way to consistently recognize this?
Mar ’25
Reply to Weird crashes when accessing Swift Array
I just wanted to give a quick update on my earlier statement: [quote='796483022, Nickkk, /thread/760029?answerId=796483022#796483022, /profile/Nickkk'] Regarding the first crash, I noticed something strange. The crash report seems to imply that a particular method called another one, which is impossible. [/quote] I was just having a look at some completely different crash reports downloaded by Xcode, and I noticed the same wrong pattern: the crash reports indicate that method A calls method B, which is impossible. In one particular case, method A that is triggered by the press of a button (and nothing else) seems to be called by method B that can be triggered by a context menu (or keyboard shortcut). The rest of the stack trace confirm that it's indeed the button that was pressed. This seems to me like a quite serious bug in how macOS creates crash reports. Should I open a new forum post and bug report to discuss this, or would you like to go on here?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’25
Reply to GKMatch.chooseBestHostingPlayer(_:) always returns nil player
What I find strange is that the Mac logs starting match with local player A:_5b773e1b128bcf2b710fda6ca683bc43 and remote players ["A:_23dc24e3273fb327ce3a17c34a6c390a"] while the iPhone logs starting match with local player A:_23dc24e3273fb327ce3a17c34a6c390a and remote players ["174148222230085984"] Note how the player id for the iPhone matches on both devices, while the player id for the Mac is different. Not sure if this is expected. At first I thought this might be related to not being able to determine the hosting player, but this also happens in the rare case when the hosting player can be determined successfully.
Topic: Graphics & Games SubTopic: GameKit Tags:
Mar ’25
Reply to Xcode downloads client crash report with reason "index 0 beyond bounds for empty array" but the stacktraces don't contain any of my app's symbols
Thanks for your insights. Unfortunately I don't have any more information about the crash: the crash report downloaded by Xcode is all I have. I think this is the first time I've seen this kind of crash. Whenever I see a crash report that gives me no clue about what the issue is, I have no choice but to assume that it's something unrelated to my own code, but if that's really the case, then in my opinion I shouldn't even get the crash report at all, since I cannot do anything about it. Looking into these reports only to realize that there's nothing I can do about it still takes quite some time when summing them all up. I thought I might still ask if there's anything I can do.
Topic: App & System Services SubTopic: General Tags:
Mar ’25
Reply to Xcode won't symbolicate .ips crash log
I often have the same issue with crash reports from other users downloaded by Xcode. Right now I had this issue with a crash report transferred from a different partition on my Mac where I tested my app on an older macOS version (macOS 12). Usually I use the atos Terminal command, but surprisingly this time that command never returns or prints anything, even after waiting for 10 minutes. When dragging the crash log to Xcode, the console prints out error: unable to locate main executable (arm64) "~/Downloads/myApp.app/Contents/MacOS/myApp" error: unable to locate main executable (arm64e) "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit" error: unable to locate main executable (arm64e) "/usr/lib/system/libdispatch.dylib" error: unable to locate main executable (arm64e) "/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation" error: unable to locate main executable (arm64e) "/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox" error: unable to locate main executable (arm64e) "/usr/lib/dyld" error: unable to locate main executable (arm64e) "/usr/lib/system/libsystem_pthread.dylib" error: unable to locate main executable (arm64e) "/usr/lib/system/libsystem_kernel.dylib" crashlog.create_target()...2 crashlog.create_target()...3 crashlog.create_target()...4 error: Unable to locate any executables from the crash log. Try loading the executable into lldb before running crashlog and/or make sure the .dSYM bundles can be found by Spotlight. error: invalid target error: invalid target error: invalid target error: invalid target error: invalid target error: invalid target which seems strange, as it isn't even able to locate the system libraries. Then I opened the crash report in TextEdit and replaced all references to the app path (previously in /Downloads) with the location of the Xcode archive (\/Users\/username\/Library\/Developer\/Xcode\/Archives\/2025-02-12\/myApp macOS 12.02.2025, 08.45.xcarchive\/Products\/Applications\/*\/myApp.app\/Contents\/MacOS\/myApp) and then Xcode symbolication seemed to work ("seemed" because the crash still doesn't make sense to me: apparently it crashed on the line window.toolbar = toolbar which works fine on macOS 15).
Feb ’25