Offered NSService freezes in own app

Originator:tempelmann
Number:rdar://23305966 Date Originated:29 Oct 2015
Status:open Resolved:
Product:OS X SDK Product Version:10.11
Classification:Other bug Reproducible:always
 
I have attached an app with source code that demonstrates an issue with OS Services I like to solve:

The app both offers a service that returns a text (taking no input)
and also uses the Services itself.

The issue is that the app shows its own offered service in its
Services menus (which isn't desired).

But even worse, if the user
chooses the service, the app does not get its Service handler
invoked until a timeout is reached, after which a cryptic error
message is shown to the user.

Ideally, it would be great if I could hide my offered services from my 
app's Services menu, because I want to offer my service only to other apps. But since I want to offer my service to ALL other apps, I believe one cannot control this "all but me" via the documented options for the Services dict in the Info.plist.
I also found no way to dynamically disable my services when my app is front, because it appears that the Services menu gets created statically from the Info.plist, and I cannot change that while my app runs, right?

If I cannot hide my own service from the Services menu, the second option would be to at least avoid the odd timeout issue that's caused if the user chooses the service inside my app. I found that if I do not declare the readSelectionFromPasteboard: method at all, then my service gets called, which is odd, - but that's solution because then I would not be able to handle other Services in my app properly, either.

Steps to Reproduce:
To test this effect, first verify that the offered service works
in other apps: Run this app, then open a text editor and use its
Services menu, choosing "• test: get text •". This invokes this
app's testGetText: method and returns the text "text from service"
to the editor. This proves that it works, in general.

Now use the Services menu in this app, choosing "• test: get text •"
again. This time, nothing happens but instead an error message gets
displayed after the timeout that's set in the Info.plist file for
the service.

Attachment download: http://files.tempel.org/Various/radar-23305966.zip

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!