Post

Replies

Boosts

Views

Activity

Cannot remove an observer <TUINSCursorUIController 0x600001844340> for the key path "visible" from <NSSavePanel 0x10ff05200> because it is not registered as an observer.
I have two NSTextField as an accessoryView of NSSavePanel. When I try to change focus in between them with a caps lock on the whole panel will crash. This will also happen when NSTextField if focused with caps lock on and i press cmd+tab (app switching). This happens on Sonoma + Sequoia beta. On top I have noticed editing NSTextField in accessoryView is completely broken on Sonoma and I can only edit it ONLY when the textfiled is using bindings. I am trying to find a workaround for the caps lock indicator being displayed. The only idea I have ATM is to observe NSApp.windows and look for TUINSWindow and force close it when it's visible. Is there any other workaround to prevent this crash? https://youtu.be/BCVjZH7684U Sample code: import Cocoa class ViewController: NSViewController { let savePanel = NSSavePanel() override func viewDidLoad() { super.viewDidLoad() let view = NSGridView(views: [[NSTextField(string: "111111")], [NSTextField(string: "22222222")]]) savePanel.accessoryView = view } override func viewWillAppear() { savePanel.runModal() } } Crash report: Cannot remove an observer <TUINSCursorUIController 0x600001844340> for the key path "visible" from <NSSavePanel 0x10ff05200> because it is not registered as an observer. ( 0 CoreFoundation 0x000000019a2522ec __exceptionPreprocess + 176 1 libobjc.A.dylib 0x0000000199d36158 objc_exception_throw + 60 2 Foundation 0x000000019b30436c -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 628 3 Foundation 0x000000019b3040a4 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 136 4 TextInputUIMacHelper 0x0000000253d9e598 -[TUINSCursorUIController deactivate:] + 416 5 AppKit 0x000000019dbda3e4 -[NSTextInputContext deactivate] + 288 6 AppKit 0x000000019da3fff4 +[NSTextInputContext currentInputContext_withFirstResponderSync:] + 228 7 AppKit 0x000000019da4f084 -[NSView _setWindow:] + 692 8 AppKit 0x000000019db7d880 -[NSTextView(NSPrivate) _setWindow:] + 216 9 AppKit 0x000000019e4da778 __21-[NSView _setWindow:]_block_invoke.146 + 268 10 CoreAutoLayout 0x00000001a2aba588 -[NSISEngine withBehaviors:performModifications:] + 88 11 AppKit 0x000000019da4f4b4 -[NSView _setWindow:] + 1764 12 AppKit 0x000000019da7712c -[NSView removeFromSuperview] + 168 13 AppKit 0x000000019dc7c0e8 -[_NSKeyboardFocusClipView removeFromSuperview] + 56 14 AppKit 0x000000019dbc5474 -[NSWindow endEditingFor:] + 368 15 AppKit 0x000000019da770d0 -[NSView removeFromSuperview] + 76 16 AppKit 0x000000019dc7c0e8 -[_NSKeyboardFocusClipView removeFromSuperview] + 56 17 AppKit 0x000000019dc7be00 -[NSCell endEditing:] + 452 18 AppKit 0x000000019dc7b994 -[NSTextField textDidEndEditing:] + 264 19 CoreFoundation 0x000000019a1d2144 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148 20 CoreFoundation 0x000000019a2663d8 ___CFXRegistrationPost_block_invoke + 88 21 CoreFoundation 0x000000019a266320 _CFXRegistrationPost + 440 22 CoreFoundation 0x000000019a1a0678 _CFXNotificationPost + 768 23 Foundation 0x000000019b2bd2c4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88 24 AppKit 0x000000019dc7b5fc -[NSTextView(NSSharing) resignFirstResponder] + 668 25 AppKit 0x000000019db2ca80 -[NSWindow _realMakeFirstResponder:] + 196 26 AppKit 0x000000019dcc1764 -[NSWindow _makeParentWindowHaveFirstResponder:] + 76 27 ViewBridge 0x00000001a296c8c0 -[NSAccessoryViewWindow makeFirstResponder:] + 80 28 AppKit 0x000000019dbdbb9c -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3148 29 AppKit 0x000000019db67504 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 288 30 AppKit 0x000000019db67210 -[NSWindow(NSEventRouting) sendEvent:] + 284 31 ViewBridge 0x00000001a296cecc -[NSAccessoryViewWindow sendEvent:] + 64 32 AppKit 0x000000019e2304f0 -[NSApplication(NSEventRouting) sendEvent:] + 1604 33 AppKit 0x000000019dc6df6c -[NSApplication _doModalLoop:peek:] + 276 34 AppKit 0x000000019dc6ce38 __35-[NSApplication runModalForWindow:]_block_invoke_2 + 56 35 AppKit 0x000000019dc6cde4 __35-[NSApplication runModalForWindow:]_block_invoke + 108 36 AppKit 0x000000019dc6c6b0 _NSTryRunModal + 100 37 AppKit 0x000000019dc6c570 -[NSApplication runModalForWindow:] + 292 38 AppKit 0x000000019e690490 -[NSSavePanel runModal] + 340 39 SavePanelAccessory 0x0000000100435ad4 $s18SavePanelAccessory14ViewControllerC14viewWillAppearyyF + 60 40 SavePanelAccessory 0x0000000100435b0c $s18SavePanelAccessory14ViewControllerC14viewWillAppearyyFTo + 36 41 AppKit 0x000000019db387f4 -[NSViewController _sendViewWillAppear] + 32 42 AppKit 0x000000019db386bc -[NSViewController _windowWillOrderOnScreen] + 80 43 AppKit 0x000000019e4e7b38 -[NSView _windowWillOrderOnScreen] + 56 44 AppKit 0x000000019e4e7ba4 -[NSView _windowWillOrderOnScreen] + 164 45 AppKit 0x000000019db38570 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 40 46 AppKit 0x000000019e4fc418 -[NSWindow _reallyDoOrderWindowAboveOrBelow:] + 1028 47 AppKit 0x000000019e4fcfec -[NSWindow _reallyDoOrderWindow:] + 64 SHORTENED
0
0
368
Aug ’24
NSSavePanel accessory view doesn't react to enter keypress
I have a textfield in accessory view of NSSavePanel. For user convenience there are default actions supported natively by macOS (such as pressing Enter, keyEquivalent). However this doesn't work for enter under Sonoma. Escape key works. Is enter keypress dangerous for malicious actors so it's not supported? I have workaround below but I am not confident if I am not violating sandbox (future proof). Original code demonstrating the issue: class ViewController: NSViewController, NSTextFieldDelegate, NSControlTextEditingDelegate { let savePanel = NSSavePanel() override func viewDidLoad() { super.viewDidLoad() let customView = NSView() let textField = NSTextField(string: "11111111") textField.delegate = self // to get focus using tab keypress savePanel.accessoryView = textField } override func viewWillAppear() { savePanel.runModal() } } Workaround: // variable set to true in delegate method controlTextDidEndEditing var didUseTextFieldWithEnterPressed = false override func performKeyEquivalent(with event: NSEvent) -> Bool { if #unavailable(macOS 14) { return super.performKeyEquivalent(with: event) } guard let panel, didUseTextFieldWithEnterPressed == true, event.type == .keyDown && (event.keyCode == UInt16(kVK_Return) || event.keyCode == UInt16(kVK_ANSI_KeypadEnter)) else { return super.performKeyEquivalent(with: event) } return panel.performKeyEquivalent(with: event) }
0
0
338
Aug ’24
Lossy option has no effect when exporting PNG to HEIF
Under Sonoma 14.4 the compression option doesn't work with PNG images. It works for JPG/HEIF. Preview can export PNG file to HEIC with compression option. What am I missing? Previously this has worked. I am trying with 0.01 and 0.9 as compression quality and the file size is the same for PNG. Is Preview using some trick to convert the image using ciContext.createCGImage? PS: Compression option of 1.0 was broken under 14.4 RC and Preview created empty file. func heifImageDataUsingDestination(at url: URL, compressionQuality : CGFloat) -> Data? { guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { return nil } guard let cgImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) else { return nil } var mutableData = NSMutableData() guard let imageDestination = CGImageDestinationCreateWithData(mutableData, "public.heic" as CFString, 1, nil) else { return nil } let options = [ kCGImageDestinationLossyCompressionQuality: compressionQuality ] as CFDictionary CGImageDestinationAddImage(imageDestination, cgImage, options) let success = CGImageDestinationFinalize(imageDestination) if success { return mutableData as Data } return nil } func heifImageDataUsingCIContext(at url: URL, compressionQuality : CGFloat) -> Data? { guard let ciImage = CIImage(contentsOf: url) else { return nil } let context = CIContext() let colorspace = ciImage.colorSpace ?? CGColorSpaceCreateDeviceRGB() let options = [CIImageRepresentationOption(rawValue: kCGImageDestinationLossyCompressionQuality as String) : compressionQuality] return context.heifRepresentation(of: ciImage, format: .RGBA8, colorSpace: colorspace, options: options) }
5
0
1.1k
Mar ’24
NSImage with SVG support - official?
I just tried on macOS 14.0 Sonoma to load SVG and it works. There is no parity on iOS17. Is this officially supported and documented? let xmlSVGImage = "<svg height=\"190\"><polygon points=\"100,10 40,180 190,60 10,60 160,180\" style=\"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;\" /></svg>" let svgData = xmlSVGImage.data(using: .utf8)! let svgImage = NSImage(data: svgData) print(svgImage) Optional(<NSImage 0x600001400140 Size={185, 190} RepProvider=<NSImageArrayRepProvider: 0x600002704220, reps:( "_NSSVGImageRep 0x60000063c1e0 Size={185, 190} ColorSpace=Generic RGB colorspace BPS=0 Pixels=0x0 Alpha=NO AppearanceName=(null)" )>>)
1
0
542
Oct ’23
How to draw image highlight like NSButtonCell in NSPopupButton
I am trying to use non-bordered pull down NSPopupButton in toolbar. The problem is the highlight which results in burning of the image. There is no burning when the NSPopupButton is bordered (however i have to subclass heavily to get the same effect). I tried to set numerous cell properties without effect. The only solution I have is to draw a substitute cell which has the same effect.How to draw the highlight the same way the NSButtonCell is doing@interface ToolbarPopUpButtonCell : NSPopUpButtonCell @end@implementation ToolbarPopUpButtonCell- (void)drawImageWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSImage *image = [self image]; NSButtonCell *buttonCell = [[NSButtonCell alloc] initImageCell:image]; [buttonCell setHighlighted:[self isHighlighted]]; [buttonCell drawImage:image withFrame:cellFrame inView:controlView]; }@endExample (left - burning effect, right - nicer overlay)https://i.stack.imgur.com/13rUe.png
0
0
673
Apr ’20
How to report AppKit bug I can't reproduce but have dozens of reports (NSControlTrackMouse)
Since macOS Catalina I started to get report I can't reproduce but I know where is it crashing.Register rsi has following selector in memory:_controlStopTracking:at:inView:mouseIsUp:SEGV_MAPERR has address 0x000059b575cd55f8 which is a result of 0x000059b575cd55e0+0x18AppKit where it crashes:if (*(int8_t *)(var_90 + 0x18) != 0x0) { [r14 _controlStopTracking:r15 at:sign_extend_64(*(int8_t *)(var_70 + 0x18)) inView:r8 mouseIsUp:r9]; }https://imgur.com/a/pXro4QFReports are coming from multiple systems/languages and I can't simulate the crash.How to report this or what can I do more (debugging)?Exception Type: SIGSEGV Exception Codes: SEGV_MAPERR at 0x59b575cd55f8 Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x00007fff64e2501d objc_msgSend + 29 1 AppKit 0x00007fff2c098af0 NSControlTrackMouse + 1491 2 AppKit 0x00007fff2c0984f4 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 129 3 AppKit 0x00007fff2c5d92b5 -[NSStepperCell trackMouse:inRect:ofView:untilMouseUp:] + 161 4 AppKit 0x00007fff2c3c86c4 -[NSDatePickerCell(NSTextFieldWithStepperDatePickerInternal) _textFieldWithStepperTrackMouse:inRect:ofView:untilMouseUp:] + 391 5 AppKit 0x00007fff2c097733 -[NSControl mouseDown:] + 747 6 AppKit 0x00007fff2c095b0d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4906 7 AppKit 0x00007fff2bfffc5c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2611 8 AppKit 0x00007fff2bfff005 -[NSWindow(NSEventRouting) sendEvent:] + 348 9 AppKit 0x00007fff2bffd37c -[NSApplication(NSEvent) sendEvent:] + 351 10 AppKit 0x00007fff2be490cf -[NSApplication run] + 706 11 AppKit 0x00007fff2be1b465 NSApplicationMain + 776 12 Dynaper 0x00000001071d9199 main (receigen.h:5142) 13 libdyld.dylib 0x00007fff6619f7fd start + 0Thread 0 crashed with x86_64 Thread State: rflags: 0x0000000000010202 rax: 0x00007ffee8a765e8 rdi: 0x00006000018e55e0 r14: 0x00006000018e55e0 rsi: 0x00007fff2cadb39d r8: 0x0000000000000091 rdx: 0x00007f9e6cd39f10 r10: 0x000059b575cd55e0 cs: 0x000000000000002b fs: 0x0000000000000000 r9: 0x00000000000007fb r15: 0x00007f9e6cd39f10 rbx: 0x0000000000000000 r11: 0x00007fff2cadb39d rip: 0x00007fff64e2501d rbp: 0x00007ffee8a766b0 gs: 0x0000000000000000 rsp: 0x00007ffee8a76468 r12: 0x000060000088dd40 rcx: 0x0000000000000000 r13: 0x00006000018e45b0
2
0
1.2k
Feb ’20
How to add tile support for HEIC image
I have noticed that the new Mojave wallpaper under macOS Catalina has been re-encoded for larger resolution and according to metadata it support tiles. I can drag out single TIFF images from preview and more info still shows the tile support for individual TIFF files. However, when I try to recreate HEIC file from those TIFF files I lose tile support. How to create HEIC image with tile support?NSMutableData *mData = [NSMutableData data]; CGImageDestinationRef destination; destination = CGImageDestinationCreateWithData((CFMutableDataRef)mData, (CFStringRef)AVFileTypeHEIC, numberOfImages,NULL); NSDictionary *options = @{(id)kCGImageDestinationLossyCompressionQuality: @(1.0), (id)kCGImagePropertyTIFFTileWidth : @(1024), //-&gt; no effect (id)kCGImagePropertyTIFFTileLength : @(1024) //-&gt; no effect}; CGImageDestinationAddImageAndMetadata(destination, imageRef, imageMetadata, (CFDictionaryRef)options);
1
0
941
Feb ’20