I'm drawing a colored gradient inside a rectangular Bezier curve within a custom View's drawRect method using drawInBezierPath. When I convert the view to a PDF using drawInBezierPath, the gradient is replaced with gray. Is this a bug, or am I doing something wrong?
Thanks!
AppKit
RSS for tagConstruct and manage a graphical, event-driven user interface for your macOS app using AppKit.
Post
Replies
Boosts
Views
Activity
Hi,
I'm trying to drag an NSTextView from one NSView to another. I'm getting the right events, but the drag animation is not coming up.
Subclassed TextView:
class MyTextView:NSTextView, NSPasteboardItemDataProvider
{
func pasteboard(_ pasteboard: NSPasteboard?, item: NSPasteboardItem, provideDataForType type: NSPasteboard.PasteboardType)
{
NSLog ("Paste")
}
override func mouseDown(with theEvent: NSEvent)
{
let pasteboardItem = NSPasteboardItem()
pasteboardItem.setDataProvider(self, forTypes: [.string])
let draggingItem = NSDraggingItem(pasteboardWriter: pasteboardItem)
draggingItem.setDraggingFrame(self.bounds, contents:.Publisher)
beginDraggingSession(with: [draggingItem], event: theEvent, source: self)
}
override func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation
{
return NSDragOperation.copy
}
}
Subclassed NSView to receive the drop event:
class DropView:NSView
{
func EnableDrop ()
{
// Registering for drag drop types
registerForDraggedTypes([NSPasteboard.PasteboardType.string, NSPasteboard.PasteboardType.URL, NSPasteboard.PasteboardType.multipleTextSelection, NSPasteboard.PasteboardType.color])
}
func shouldAllowDrag(_ draggingInfo: NSDraggingInfo) -> Bool
{
return true
}
override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
// To show a copy tooltip during drop
return NSDragOperation.copy
}
override func prepareForDragOperation(_ sender: NSDraggingInfo) -> Bool
{
return true
}
override func performDragOperation(_ draggingInfo: NSDraggingInfo) -> Bool {
let draggedview = draggingInfo.draggingSource as! NSView
NSLog ("Drop received")
return true
}
}
When I create my view in the ViewController, I do "myviewobj.EnableDrop()" to receive drop events. However as stated above, I'm not able to see the drag animation happening, however, I do get events for it.
I have an Objective-C App that has worked perfectly until Monterey was released. The app is activated and displays a window when it’s hotkey is typed. The problem is that—starting in Monterey—if the cursor is in an html Password field of ANY website in ANY browser, the app’s window does not display. After many many hours of debugging, I have determined that the problem is that in this case, [NSApp activateIgnoringOtherApps:YES] never activates the app, and that [myWindow makeKeyAndOrderFront:nil] does nothing. In this case, if I display a window using [NSApp runModalForWindow:myWindow], the window does display, but is not key until it is clicked, at which point the app activates.
Note that everything works properly with the cursor in any browser field other than a Password field, or in any other app. It also works with the cursor anywhere in MacOS versions 10.12 through 11.
Is this is some kind of new security feature? Is this a bug or is there a workaround for this? I there a low-level non-Cocoa way to activate an app?
I have a macOS app made with the Electron framework. Ever since I updated to macOS Sonoma, I've been facing a random crash whenever I click on the app menu/apple menu. This is not reproducible but happens quite often. On checking the crash report, I can notice that nil is being provided as an input to __NSPlaceholderDictionary initWithObjects method, but this crash does not happen in macOS Ventura or older versions. Is this due to any new validation added to the above method in macOS Sonoma ?
Application Specific Backtrace 0:
0 CoreFoundation 0x000000018c6c08c0 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x000000018c1b9eb4 objc_exception_throw + 60
2 CoreFoundation 0x000000018c5d7fa4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 728
3 CoreFoundation 0x000000018c5d7ca0 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 52
4 AppKit 0x000000019059d56c __NSSearchFieldCellGetSymbolImageDict_block_invoke + 3616
5 libdispatch.dylib 0x000000018c3c1910 _dispatch_client_callout + 20
6 libdispatch.dylib 0x000000018c3c314c _dispatch_once_callout + 32
7 AppKit 0x000000019059c368 NSSearchFieldCellGetSearchImage + 596
8 AppKit 0x000000018feea85c -[NSSearchFieldCell(NSSearchFieldCell_Local) _adjustSearchButtonCellImages::] + 216
9 AppKit 0x000000018fff2364 -[NSSearchFieldCell initWithCoder:] + 1040
10 AppKit 0x000000018fe6ed74 -[NSClassSwapper initWithCoder:] + 812
11 UIFoundation 0x0000000191161a64 UINibDecoderDecodeObjectForValue + 668
12 UIFoundation 0x00000001911617b0 -[UINibDecoder decodeObjectForKey:] + 312
13 AppKit 0x000000018fe6f2f8 -[NSControl initWithCoder:] + 368
14 AppKit 0x000000018fe6f744 -[NSTextField initWithCoder:] + 72
15 AppKit 0x000000018fff1ef8 -[NSSearchField initWithCoder:] + 52
16 AppKit 0x000000018fe6ed74 -[NSClassSwapper initWithCoder:] + 812
17 UIFoundation 0x0000000191161a64 UINibDecoderDecodeObjectForValue + 668
18 UIFoundation 0x0000000191161bec UINibDecoderDecodeObjectForValue + 1060
19 UIFoundation 0x00000001911617b0 -[UINibDecoder decodeObjectForKey:] + 312
20 AppKit 0x000000018fe30b6c -[NSView initWithCoder:] + 944
21 AppKit 0x000000018fe6e804 -[NSCustomView initWithCoder:] + 76
22 UIFoundation 0x0000000191161a64 UINibDecoderDecodeObjectForValue + 668
23 UIFoundation 0x00000001911617b0 -[UINibDecoder decodeObjectForKey:] + 312
24 AppKit 0x000000018fdfdecc -[NSNibConnector initWithCoder:] + 88
25 AppKit 0x000000018fdfde1c -[NSNibOutletConnector initWithCoder:] + 336
26 UIFoundation 0x0000000191161a64 UINibDecoderDecodeObjectForValue + 668
27 UIFoundation 0x0000000191161bec UINibDecoderDecodeObjectForValue + 1060
28 UIFoundation 0x00000001911617b0 -[UINibDecoder decodeObjectForKey:] + 312
29 AppKit 0x000000018fdfceb8 -[NSIBObjectData initWithCoder:] + 136
30 UIFoundation 0x0000000191161a64 UINibDecoderDecodeObjectForValue + 668
31 UIFoundation 0x00000001911617b0 -[UINibDecoder decodeObjectForKey:] + 312
32 AppKit 0x000000018fdfccd0 loadNib + 264
33 AppKit 0x000000018fdfc34c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 560
34 AppKit 0x000000018fdfc050 -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 180
35 Shortcut 0x00000001cc34f6d4 -[SCTSearchManager loadNib] + 60
36 Shortcut 0x00000001cc356bb8 -[SCTSearchManager akm_installShortcutView] + 200
37 Shortcut 0x00000001cc3569b4 -[SCTSearchManager menuNeedsUpdate:] + 24
38 CoreFoundation 0x000000018c640780 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
39 CoreFoundation 0x000000018c6d49a8 ___CFXRegistrationPost_block_invoke + 88
40 CoreFoundation 0x000000018c6d48f0 _CFXRegistrationPost + 440
41 CoreFoundation 0x000000018c60f434 _CFXNotificationPost + 764
42 Foundation 0x000000018d700c74 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
43 AppKit 0x0000000190445318 -[NSMenuTrackingSession sendBeginTrackingNotifications] + 204
44 AppKit 0x00000001904495f4 -[NSMenuTrackingSession beginTrackingSession] + 184
45 AppKit 0x00000001904ed170 -[NSMenuBarTrackingSession beginTrackingSession] + 188
46 AppKit 0x00000001904ec1e4 -[NSMenuBarTrackingSession _mouseDownEventHandler:] + 128
47 AppKit 0x00000001904ec14c -[NSMenuBarTrackingSession handleEvent:] + 248
48 AppKit 0x00000001904ec02c __61-[NSMenuBarTrackingSession _addMouseDownEventMonitorIfNeeded]_block_invoke + 192
49 AppKit 0x0000000190020624 _NSSendEventToDequeuingObservers + 252
50 AppKit 0x00000001905f919c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2260
51 AppKit 0x000000018fe1843c -[NSApplication run] + 476
52 Electron Framework 0x00000001128cefd0 _ZN8electron5fuses45IsLoadBrowserProcessSpecificV8SnapshotEnabledEv + 94056
53 Electron Framework 0x00000001128cd4a0 _ZN8electron5fuses45IsLoadBrowserProcessSpecificV8SnapshotEnabledEv + 87096
54 Electron Framework 0x0000000115494168 _ZN2v88internal20SetupIsolateDelegate13SetupBuiltinsEPNS0_7IsolateEb + 18052380
55 Electron Framework 0x00000001154606ec _ZN2v88internal20SetupIsolateDelegate13SetupBuiltinsEPNS0_7IsolateEb + 17840800
I have a doc, xib based project.
it has an NSCollectionView, which properly displays the data. including items and section headers.
I have drag n drop enabled where I can drop into the collectionView, and I generate a new object. this is NOT a reordering issue (yet)
when I drop into the collectionView, if the drop is on top of a HeaderView, the drop is canceled (before it gets to my delegate code.) But more importantly : the Header views are entirely ignored in every step of the drag and drop. the hinting, only ever shows up adjacent to a collectionViewItemView, Never below or above the section header. The drop ALWAYS has a section of zero in its index path. regardless of where the drop is.
I tried to override this behavior in both the validate drop and accept drop methods. with a great deal of frustration and struggle I discovered that I cannot compare the placement of my header views, because the frames of those views are all at the base origin point.
is this normal behavior? Has anyone else run into this? is there a fix?
My app (AppKit, not SwiftUI) displays a small utility window. I can place it over the menu bar, or in the area beside the notch on my MacBook Pro (when it is a secondary screen), but if the screen goes to sleep and I wake it, macOS has moved the window off the menu bar or down out of the notch area.
Is there any way to indicate a window should never be moved by the OS?
Xcode contains several crash reports downloaded from users of my app. Thread 0 apparently crashes after calling NSApp.runModalForWindow(_:) (within the redacted stacktrace rows 17-19 that are locations in my own code). All the other threads only contain calls to system code.
What could cause such a crash?
...
Code Type: ARM-64
Parent Process: launchd [1]
User ID: 501
...
OS Version: macOS 13.5.2 (22G91)
...
Crashed Thread: 0
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018800c728
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [61015]
Thread 0 Crashed:
0 AppKit 0x000000018800c728 -[NSApplication _crashOnException:] + 240 (NSApplication.m:6808)
1 AppKit 0x0000000187e54a10 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 644 (NSCATransaction.m:98)
2 AppKit 0x0000000188530cfc ___NSRunLoopObserverCreateWithHandler_block_invoke + 64 (AppKit_Internal.h:745)
3 CoreFoundation 0x0000000184b059f0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 (CFRunLoop.c:1789)
4 CoreFoundation 0x0000000184b058dc __CFRunLoopDoObservers + 532 (CFRunLoop.c:1902)
5 CoreFoundation 0x0000000184b04f14 __CFRunLoopRun + 776 (CFRunLoop.c:2944)
6 CoreFoundation 0x0000000184b044b8 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
7 HIToolbox 0x000000018e356df0 RunCurrentEventLoopInMode + 292 (EventLoop.c:455)
8 HIToolbox 0x000000018e356a80 ReceiveNextEventCommon + 220 (EventBlocking.c:311)
9 HIToolbox 0x000000018e356984 _BlockUntilNextEventMatchingListInModeWithFilter + 76 (EventBlocking.c:171)
10 AppKit 0x0000000187d2b97c _DPSNextEvent + 636 (CGDPSReplacement.m:818)
11 AppKit 0x0000000187d2ab18 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716 (appEventRouting.m:407)
12 AppKit 0x0000000187f63bd0 -[NSApplication _doModalLoop:peek:] + 216 (NSApplication.m:3469)
13 AppKit 0x0000000187f62ad4 __35-[NSApplication runModalForWindow:]_block_invoke_2 + 56 (NSApplication.m:3516)
14 AppKit 0x0000000187f62a80 __35-[NSApplication runModalForWindow:]_block_invoke + 108 (NSApplication.m:3516)
15 AppKit 0x0000000187f62364 _NSTryRunModal + 100 (NSModal.m:25)
16 AppKit 0x0000000187f62224 -[NSApplication runModalForWindow:] + 292 (NSApplication.m:3516)
...
20 AppKit 0x0000000187ed34cc -[NSApplication(NSResponder) sendAction:to:from:] + 440 (appEventRouting.m:1888)
21 AppKit 0x0000000187ed32e4 -[NSControl sendAction:to:] + 72 (NSControl.m:1459)
22 AppKit 0x0000000187fda170 -[NSTableView _sendAction:to:row:column:] + 116 (NSTableView.m:9022)
23 AppKit 0x0000000187fd8d70 -[NSTableView mouseDown:] + 4224 (NSTableView.m:11191)
24 AppKit 0x0000000187ecdef0 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3476 (winEventRouting.m:1003)
25 AppKit 0x0000000187e58b2c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364 (winEventRouting.m:402)
26 AppKit 0x0000000187e587ec -[NSWindow(NSEventRouting) sendEvent:] + 284 (winEventRouting.m:257)
27 AppKit 0x0000000187e57b30 -[NSApplication(NSEvent) sendEvent:] + 1556 (appEventRouting.m:0)
28 AppKit 0x00000001880a7c48 -[NSApplication _handleEvent:] + 60 (NSApplication.m:3342)
29 AppKit 0x0000000187d1efa0 -[NSApplication run] + 500 (NSApplication.m:3430)
30 AppKit 0x0000000187cf63cc NSApplicationMain + 880 (NSApplication.m:9413)
31 MyApp 0x0000000102980cd0 main + 128 (main.swift:12)
32 dyld 0x00000001846cff28 start + 2236 (dyldMain.cpp:1165)
...
Xcode contains several crash reports downloaded from users of my app. Thread 0 apparently crashes at [CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink], but there's not a single stacktrace line that contains code within my app, so I have no idea what this means or how to reproduce it.
What could cause such a crash?
Code Type: X86-64 (Native)
Parent Process: launchd [1]
User ID: 501
...
OS Version: macOS 14.0 (23A344)
...
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process: exc handler [1920]
Thread 0 Crashed:
0 AppKit 0x00007ff81c3730c1 -[NSApplication _crashOnException:] + 289 (NSApplication.m:7290)
1 AppKit 0x00007ff81c175ea5 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 853 (NSCATransaction.m:98)
2 AppKit 0x00007ff81cc43339 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41 (AppKit_Internal.h:760)
3 CoreFoundation 0x00007ff818a13836 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 (CFRunLoop.c:1789)
4 CoreFoundation 0x00007ff818a1375a __CFRunLoopDoObservers + 493 (CFRunLoop.c:1902)
5 CoreFoundation 0x00007ff818a12cdc __CFRunLoopRun + 850 (CFRunLoop.c:2946)
6 CoreFoundation 0x00007ff818a12372 CFRunLoopRunSpecific + 557 (CFRunLoop.c:3420)
7 HIToolbox 0x00007ff82327e9d9 RunCurrentEventLoopInMode + 292 (EventLoop.c:455)
8 HIToolbox 0x00007ff82327e616 ReceiveNextEventCommon + 201 (EventBlocking.c:311)
9 HIToolbox 0x00007ff82327e531 _BlockUntilNextEventMatchingListInModeWithFilter + 66 (EventBlocking.c:171)
10 AppKit 0x00007ff81c01a0c5 _DPSNextEvent + 880 (CGDPSReplacement.m:806)
11 AppKit 0x00007ff81c90b150 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1304 (appEventRouting.m:410)
12 AppKit 0x00007ff81c00b63a -[NSApplication run] + 603 (NSApplication.m:3488)
13 AppKit 0x00007ff81bfdf670 NSApplicationMain + 816 (NSApplication.m:10105)
14 MyApp 0x0000000100627071 main + 129 (main.swift:12)
15 dyld 0x00007ff8185b03a6 start + 1942 (dyldMain.cpp:1269)
Thread 1:
0 libsystem_kernel.dylib 0x00007ff8188f9a2e mach_msg2_trap + 10
1 libsystem_kernel.dylib 0x00007ff818907e4a mach_msg2_internal + 84 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x00007ff818900b6e mach_msg_overwrite + 653 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x00007ff8188f9d1f mach_msg + 19 (mach_msg.c:323)
4 CoreFoundation 0x00007ff818a14475 __CFRunLoopServiceMachPort + 143 (CFRunLoop.c:2624)
5 CoreFoundation 0x00007ff818a12ee5 __CFRunLoopRun + 1371 (CFRunLoop.c:3007)
6 CoreFoundation 0x00007ff818a12372 CFRunLoopRunSpecific + 557 (CFRunLoop.c:3420)
7 AppKit 0x00007ff81c1773e0 _NSEventThread + 122 (NSEvent.m:5493)
8 libsystem_pthread.dylib 0x00007ff818939202 _pthread_start + 99 (pthread.c:904)
9 libsystem_pthread.dylib 0x00007ff818934bab thread_start + 15
Hello,
here is the block where arrayController is nil :
{
NSData * data;
NSError * error;
Class klass;
if(_arrayController != nil) // nil !
{
selected = [_arrayController selectedObjects];
arranged = [_arrayController arrangedObjects];
if([selected count] > 0)
{
_currentObject = [selected objectAtIndex:0];
if(_currentObject != nil)
{
data = [_currentObject valueForKey:kVrRoot];
klass = [NSMutableDictionary class];
_vrRoot =
[NSKeyedUnarchiver unarchivedObjectOfClass:klass fromData:data error:&error];
}else
{
_vrRoot = [NSMutableDictionary new];
data = [NSKeyedArchiver archivedDataWithRootObject:_vrRoot requiringSecureCoding:YES error:&error];
}
}
}
}
I use this for years so I don't no what's wrong.
I have had this issue for a long time. If I configure any auto layout constraints in TableViewCell, I get extremely weird layout behavior in IB designer; however, layout is completely good during runtime.
For example, with a completely new project and a single NSTableView on the main view, I get:
If I resize main view, the tableview won't get resized
Every time I reopen the project, the tableview would shrink by height.
It seems the shrinked height is doubled every time. For example, in the following screenshot, the gap is 56. Next reopen will double the gap to 112.
Is this a known bug? I would want to file bug report at https://feedbackassistant.apple.com.
Hello,
Is it possible fill NSpastebard with public.file-url which will initially point the an empty file.
And when Finder will paste the file, my Application will download it and Finder will wait for the completion of the download.
My goal is not to use drag & drop.
I saw that Microsoft RDP client is doing file download using this way. But I don't know how it works. Empty file is created in sandbox.
I have a Mac doc based app.
I have save methods setup (they sort of work... I'm trying to get them up and running)
I'm using NSSecureCoding, with NSObjects in Swift. It has been unusually frustrating.
I have run into something I find wildly difficult to even explain.
I can save a new document that has not been saved yet. it loads as expected.
but if I make a change to a doc I have already saved, and save that, ny file gets wiped out. my save code is called, and the app wipes all of the data out of the saved file. The file exists, but it's emptied.
it goes from around ~200k in size to 2k in size.
there's no error that I have identified. It just wipes my file. So I have NO idea if it's something I did.
docs are... unhelpful. internet searches... are unhelpful.
this is just one of a number of errors I have to figure out, but it is massively complicating everything else.
any ideas welcome.
I have an interesting challenge, but I do not know where to start.
given an NSTextView in an NSScrollView, and enough text in the textView to enable scrolling, how do you determine the location of a single word, and jump to it?
we see this sort of behavior in Find panels in Most text editors. So it can be done.
additionally, I would very much like to find some kind of predetermined... elements in the text. as a link or an image is not text but can be inline with the text (in Attributed strings) I would like to put an element in the text that is not text, but is targetable and capable of being tagged with some kind of reference. Almost like a bookmark, in which I can scroll to. I have determined that I could use URL Links. But they are so fragile.
With my continued experiments with TextKit2, I'm trying to figure out what sets the properties paragraphSeparatorRange and paragraphContentRange on a NSTextParagraph. These seem to be computed properties (or at least they cannot be directly set via public API).
var paragraph = NSTextParagraph(attributedString: NSAttributedString(string: "It was the best of times.\n"))
print("attributes: \(paragraph.attributedString.attributes(at: 0, effectiveRange: nil))")
print("paragraphSeparatorRange: \(String(describing: paragraph.paragraphSeparatorRange))")
print("paragraphContentRange: \(String(describing: paragraph.paragraphContentRange))")
In the above example, both paragraphSeparatorRange and paragraphContentRange are nil.
However, when using NSTextLayoutManager/NSTextContentStorage they are set.
let layoutManager = NSTextLayoutManager()
let container = NSTextContainer(size: NSSize(width: 400, height: 400))
layoutManager.textContainer = container
let contentStorage = NSTextContentStorage()
contentStorage.textStorage = NSTextStorage(string: "It was the best of times.\n")
contentStorage.addTextLayoutManager(layoutManager)
layoutManager.enumerateTextLayoutFragments(from: contentStorage.documentRange.location, options: .ensuresLayout) { textLayoutFragment in
print("layoutFragment: \(textLayoutFragment)")
print("textElement: \(String(describing: textLayoutFragment.textElement))")
print("textElement.range: \(String(describing: textLayoutFragment.textElement?.elementRange))")
let paragraph = textLayoutFragment.textElement as! NSTextParagraph
print("paragraphContentRange: \(String(describing: paragraph.paragraphContentRange))")
print("paragraphSeparatorRange: \(String(describing: paragraph.paragraphSeparatorRange))")
return true
}
Would appreciate any ideas on how these values are computed/set. Thanks
Hello,
I need to change the text of an NSScrollView at run time, but the command below is not working:
ScrViwRegras.documentView?.insertText (rules.retornaTextoRegras())
Where Rules is a struct that has the returnTextoRegras() method that returns the new text.
Has anyone had this problem?
Xcode 15.0.1 in MacBook Air not iOS), Swift 5,
Hugs
If I use -[NSView dataWithPDFInsideRect:] to create a PDF from an NSTextView, I get a single-page PDF with stuff past the bottom cut off. What do I need to do to get pagination to happen? Would embedding the NSTextView in an NSScrollView help?
This message is logged in Xcode when I start editing a text field in my macOS app.
This started appearing in Sonoma. This doesn't happen in Ventura (same Xcode project).
Every text field in the app is affected, regardless of the window.
What could be the cause of this?
The code below does not work properly in macos sonoma.
I tested it on multiple Macs (mini, m1, intel), but it does not work the same way.
(Normal operation in sonoma preview version and previous versions)
NSOpenPanel* openPanel = [NSOpenPanel openPanel]
Symptoms:
When you press the button, the cursor changes to a whirlwind icon.
My application and another system service (openAndSavePanelService) become "Not Responding".
However, after a few minutes, this condition is resolved and my application returns to normal, but openAndSavePanelService continues to be in the "Not Responding" state.
Suppose:
Looking at the attached spindump, it is assumed that when openPanel init is called, a problem occurs in the process of communicating with xpc and the system service (openAndSavePanelService) for displaying the dialog box.
What I tried:
Without creating an instance when pressing the button NSOpenPanel* g_openPanel = [NSOpenPanel openPanel] When the task is attempted in main and the button is pressed, openPanel was attempted with the created instnace, but failed.
Tried to work with NSOpenPanel* g_openPanel = [NSOpenPanel openPanel] via dispatch_async(dispatch_get_main_queue(), { ... }) but failed.
I found similar questions on forums but they didn't help.
https://developer.apple.com/forums/thread/104442?answerId=332068022#332068022
Project environment:
Cocoa project
Application is agent(UIElement)
Hardened Runtime (apple event checked)
No Sandbox
Network Extension
System Extension
Deployment Target: 10.9
Could it be a permission issue? Is there anything else worth trying?
I wanted to add some dock menu options for my application when it is not running. These dock menu options can be used to launch the application. I came across dock TilePlugin that can be used to add these dock options. But one of the comments in this forum discussion mentions that these Plugins are not allowed if you want ot publish your application in the appStore.
Can someone confirm this? If this is true, then Is there some other solution that can be used to add the dock options which appear when the application is not running, and can be used to launch the application?
Also do the recent open Files appear using this plugin mechanism?
I have received a few crash reports for my app "Find Any File" with an assertion failure as follows:
assertion failure: "displayTiming != ((void *)0)" -> %lld
Googling this turns up nothing, though.
I wonder if someone has some insight into why this might happen, and how to prevent it.
One reporting user suggests that it happens when my app shows a very long list of items in an NSTableView (>10000 elements).
I have 4 reports from 3 users, and the main thread is doing something related to the table view each time, though not the same (the few other threads are all idle):
Crash 1, in macOS 14.0 (23A344:
Thread 0:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x182c69400 objc_msgSend + 0
1 AppKit 0x186f15400 -[CALayer(NSViewVisibleRect) NS_viewVisibleRectDidChange] + 40
2 AppKit 0x186900e10 NSViewHierarchyInvalidateVisibleRect + 276
3 AppKit 0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
4 AppKit 0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
5 AppKit 0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
6 AppKit 0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
7 AppKit 0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
8 AppKit 0x1869990e0 -[NSView translateOriginToPoint:] + 164
9 AppKit 0x186984108 -[NSClipView _immediateScrollToPoint:] + 420
10 AppKit 0x186983eb8 -[NSClipView scrollToPoint:] + 184
11 AppKit 0x186998d80 -[NSScrollView scrollClipView:toPoint:] + 84
12 AppKit 0x1869448dc -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 480
13 AppKit 0x186b65b24 __62-[NSScrollingBehaviorConcurrentVBL _stopGestureScrollTracking]_block_invoke + 192
14 AppKit 0x186e6a6e8 ___NSMainRunLoopPerformBlockInModes_block_invoke + 44
15 CoreFoundation 0x18310b8c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
Crash 2, in macOS 14.1.1 (23B81):
Thread 0:: Dispatch queue: com.apple.main-thread
0 CoreFoundation 0x18ba401f4 DYLD-STUB$$_Block_object_assign + 0
1 libsystem_blocks.dylib 0x18b506118 _call_copy_helpers_excp + 80
2 libsystem_blocks.dylib 0x18b505c68 _Block_copy + 376
3 libdispatch.dylib 0x18b641c7c _dispatch_Block_copy + 32
4 libdispatch.dylib 0x18b658df0 _dispatch_source_set_handler + 92
5 CoreFoundation 0x18b99e1e4 __CFRunLoopCopyMode + 540
6 CoreFoundation 0x18b8b7458 CFRunLoopAddObserver + 220
7 AppKit 0x18f0a687c _PerfAddRunLoopObserver + 192
8 AppKit 0x18f87cd60 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 368
9 AppKit 0x18f323318 -[_NSScrollingConcurrentEventMonitor startMonitoring] + 380
10 AppKit 0x18f321df8 -[NSScrollingBehaviorConcurrentVBL _scrollView:trackGestureScrollWithEvent:] + 884
11 AppKit 0x18f2e67f8 -[NSScrollingBehaviorConcurrentVBL scrollView:scrollWheelWithEvent:] + 512
12 AppKit 0x18f241770 forwardMethod + 252
13 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
14 AppKit 0x18f241770 forwardMethod + 252
15 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
16 AppKit 0x18f241770 forwardMethod + 252
17 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
18 AppKit 0x18f241770 forwardMethod + 252
19 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
20 AppKit 0x18fc45880 -[NSCollectionView scrollWheel:] + 180
21 AppKit 0x18f241770 forwardMethod + 252
22 AppKit 0x18f241770 forwardMethod + 252
23 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
24 AppKit 0x18f241770 forwardMethod + 252
25 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
26 AppKit 0x18f241770 forwardMethod + 252
27 AppKit 0x18f2e62a0 -[NSView scrollWheel:] + 408
28 AppKit 0x18f1d27b0 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 652
As you can see, there's no code of mine involved at the time of crash.
The other (and older) reports are similar, in macOS 13.6.1 and macOS 13.1. All four happened on ARM architecture (which may not be significant due to small number of samples). Memory use of app was not critical (in one case it was about 9 GB total, in others below 4 GB).
The "Binary Images" section only lists Apple libs, apart from my app's. So, there seems to be no 3rd party ext involved.
I've attached a full report as well.
Full report of Crash 1