Showing NSPopover from status bar item sometimes results in: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.

Showing a popover from a status bar item. Sometimes results in this being logged out:

Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.

When this happens, the popover appears at 0.0,0.0 (lower left) of the screen for a second... before snapping to the proper position.

Code:

  NSStatusBarButton *statusButton = _statusItem.button;


 [_popover showRelativeToRect:statusButton.bounds ofView:statusButton preferredEdge:NSMinYEdge];



The user can add or remove the status item in this app...the issue I notice usually happens the second time the popover gets presented. Looks like the popover can be trying to present before the status item button's position is set?

Workaround that seems to be working for now is to wrap the call to show the popover inside a dispatch_after block with a short delay.

Showing NSPopover from status bar item sometimes results in: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.
 
 
Q