CharlieHess/node-mac-notifier

event.response is not always populated with the actual response, just empty string

Closed this issue · 5 comments

Sorry for hitting you with so many issues. I create them because I care ❤️ .

This is a strange issue that I've run into.

Occasionally, if my response in the reply field is pasted, the event.response property passed back to the reply callback is just an empty string. I usually have to try several times to reproduce the empty string behavior. I put together a sample app demonstrating it: https://github.com/ccnokes/electron-mac-notifier.

Let me know if you have any questions and can reproduce it. Also, I'd be happy to try to dig into the code and see what's going on...I would just need some pointers on how to debug/set breakpoints in the ObjectiveC stuff.

That's interesting– is there any pattern to the pasted content? Perhaps if the paste includes more than plaintext? This is probably a good spot to start investigating. I've just been using lldb for debugging.

As far as patterns to the pasted content -- usually longer content seemed to trigger it. I tried lots of different stuff and even used a ClipboardViewer app that gives you info on the content types of the clipboard and it seemed to happen regardless of content type.

Thanks, I'll look into it and get back to you here when I find something.

Sorry for taking such a long time to get back to you. Using my very limited debugging skills on this stuff, I think I've isolated it to this line handler:
https://github.com/CharlieHess/node-mac-notifier/blob/master/notification_center_delegate.mm#L20

On line 20, when I add these lines

  // the handler is always called but sometimes info->response is empty

  // not sure if this is necessary, just make sure 100% sure it's a C style string
  const char * responseStr = (char *)info->response;
  NSLog(@"info->response:%s", responseStr); // log it

and the content is long-ish and pasted, it'll usually log out (in Console) "info->response:" (empty string), and that's what the JS gets as the event.response property.

But here when I add an NSLog, https://github.com/CharlieHess/node-mac-notifier/blob/master/notification_center_delegate.mm#L49, it's always correctly populated with the string.

NSLog(@"response:%s", notification.response.string.UTF8String);

Hopefully that's helpful. I'm assuming you don't see this issue, so it's pretty strange that I get it so consistently. I'm not sure what could be causing it.

Yep, I'm able to reproduce this any time I paste a long block of text; I wonder if it's hitting some size constraint because of the struct. I'll experiment.

After further investigation I believe this is a symptom of #7.