-[NSView showDefinitionForAttributedString:atPoint:] fails in windows with custom background colors

Originator:markus.stange
Number:rdar://26476091 Date Originated:2016-05-25
Status:Open Resolved:
Product:OS X SDK Product Version:10.11
Classification:Serious Bug Reproducible:Always
 
Summary:
Invoking a dictionary popup by calling -[NSView showDefinitionForAttributedString:atPoint:] does not work if the view's NSWindow has a backgroundColor that is a custom subclass of NSColor.

Steps to Reproduce:
1. Compile and run the attached code file as indicated at the top of the file.
2. Click anywhere in the window that opens.

or, alternatively:

1. Create a subclass of NSColor.
2. Create an instance of that subclass, and call [yourNSWindow setBackgroundColor:yourColor] with it.
3. For any NSView inside that window, call [yourNSView showDefinitionForAttributedString:yourString atPoint:yourPoint];

Expected Results:
A dictionary lookup panel should open, describing the supplied string.

Actual Results:
No panel is opened. The following error is printed to the console:
Lookup: Unhandled exception 'NSObjectNotAvailableException' caught in -[LULookupDefinitionModule showDefinitionForString:range:options:originProvider:inView:]

In the system console, there is an additional error from inside LookupViewService, the important part being:
Exception: decodeObjectForKey: class "MyColor" not loaded or does not exist

The full error message is:
2016-05-25 3:05:03.512 PM LookupViewService[95935]: <NSXPCConnection: 0x7f92306338e0> connection from pid 95934: Warning: Exception caught during decoding of received message, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
<NSInvocation: 0x7f9232829520>
return value: {v} void
target: {@} 0x0
selector: {:} bootstrap:withReply:
argument 2: {{?=@@@@{CGRect={CGPoint=dd}{CGSize=dd}}Icc@@@}} <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>
argument 3: {@?} 0x0 (block)

Exception: decodeObjectForKey: class "MyColor" not loaded or does not exist


Version:
Version 7.3.1 (7D1014) & 10.11.6 Beta (15G7a)

Notes:
We have to work around this in Firefox, because we use a custom window background color.

Configuration:
This occurs on all versions of Mac OS 10.11, as far as I know. It sounds like it did not occur on 10.10, but I have not verified that part.

Attachments:
'main.mm' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!