Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener crashes the renderer process in Electron sometimes #14

Open
KishanBagaria opened this issue Apr 27, 2020 · 5 comments
Open

Listener crashes the renderer process in Electron sometimes #14

KishanBagaria opened this issue Apr 27, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@KishanBagaria
Copy link
Contributor

So I can't repro this consistently but it happens when a contact is mutated:

/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer)[13409]: ../../third_party/electron_node/src/node_api.cc:1064:napi_status napi_call_threadsafe_function(napi_threadsafe_function, void *, napi_threadsafe_function_call_mode): Assertion `(func) != nullptr' failed.
 1: 0x115de2135 node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x115de1ebf node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x115dbe283 napi_call_threadsafe_function [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x11b7e7897 invocation function for block in SetupListener(Napi::CallbackInfo const&) [/Users/kishan/Dropbox/Kishan/foo/node_modules/node-mac-contacts/build/Release/contacts.node]
 5: 0x7fff35262864 -[__NSObserver _doit:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
 6: 0x7fff32bf09cf __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 7: 0x7fff32bf0963 ___CFXRegistrationPost1_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 8: 0x7fff32bf08d8 _CFXRegistrationPost1 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 9: 0x7fff32bf0544 ___CFXNotificationPost_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
10: 0x7fff32bc06bd -[_CFXNotificationRegistrar find:object:observer:enumerator:] [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
11: 0x7fff32bbfb69 _CFXNotificationPost [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
12: 0x7fff35236866 -[NSNotificationCenter postNotificationName:object:userInfo:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
13: 0x7fff4564edfe -[ABAddressBookChangesNotifier nts_SendAddressBookDidSaveNotificationsWithPublicUserInfo:privateUserInfo:privateTablesChanged:] [/System/Library/PrivateFrameworks/AddressBookCore.framework/Versions/A/AddressBookCore]
14: 0x7fff455d7b68 -[ABAddressBookChangesNotifier myContextDidSave:] [/System/Library/PrivateFrameworks/AddressBookCore.framework/Versions/A/AddressBookCore]
15: 0x7fff32bf09cf __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
16: 0x7fff32bf0963 ___CFXRegistrationPost1_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
17: 0x7fff32bf08d8 _CFXRegistrationPost1 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
18: 0x7fff32bf0544 ___CFXNotificationPost_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
19: 0x7fff32bc06bd -[_CFXNotificationRegistrar find:object:observer:enumerator:] [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
20: 0x7fff32bbfb69 _CFXNotificationPost [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
21: 0x7fff35236866 -[NSNotificationCenter postNotificationName:object:userInfo:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
22: 0x7fff326f32b3 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postContextDidSaveNotificationWithUserInfo:] [/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData]
23: 0x7fff326b161f -[NSManagedObjectContext(_NSInternalAdditions) _didSaveChanges] [/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData]
24: 0x7fff326a6d71 -[NSManagedObjectContext save:] [/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData]
25: 0x7fff455d35f3 -[ABManagedObjectContext save:] [/System/Library/PrivateFrameworks/AddressBookCore.framework/Versions/A/AddressBookCore]
26: 0x7fff31fb4126 -[CNCDSaveRequestExecutor executeSaveRequest:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
27: 0x7fff31fb3d89 __71+[CNCDSaveRequestExecutor executeSaveRequest:inPersistenceStack:error:]_block_invoke [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
28: 0x7fff49cc527d __70-[CNCDPersistenceContext performBlockAndWaitWithManagedObjectContext:]_block_invoke [/System/Library/PrivateFrameworks/ContactsPersistence.framework/Versions/A/ContactsPersistence]
29: 0x7fff326be789 developerSubmittedBlockToNSManagedObjectContextPerform [/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData]
30: 0x7fff6cae8658 _dispatch_client_callout [/usr/lib/system/libdispatch.dylib]
31: 0x7fff6caf46ec _dispatch_lane_barrier_sync_invoke_and_complete [/usr/lib/system/libdispatch.dylib]
32: 0x7fff326be675 -[NSManagedObjectContext performBlockAndWait:] [/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData]
33: 0x7fff49cc5222 -[CNCDPersistenceContext performBlockAndWaitWithManagedObjectContext:] [/System/Library/PrivateFrameworks/ContactsPersistence.framework/Versions/A/ContactsPersistence]
34: 0x7fff31fb3c15 +[CNCDSaveRequestExecutor executeSaveRequest:inPersistenceStack:error:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
35: 0x7fff31fcb084 -[CNCoreDataMapperX executeSaveRequest:response:authorizationContext:error:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
36: 0x7fff31f74ee5 __83-[CNDataMapperContactStore executeSaveRequest:response:authorizationContext:error:]_block_invoke [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
37: 0x7fff6cd62ba8 os_activity_apply_f [/usr/lib/system/libsystem_trace.dylib]
38: 0x7fff31fb6d6d -[_CNContactsLogger saving:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
39: 0x7fff31f74c68 -[CNDataMapperContactStore executeSaveRequest:response:authorizationContext:error:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
40: 0x11b7e71a8 AddNewContact(Napi::CallbackInfo const&) [/Users/kishan/Dropbox/Kishan/foo/node_modules/node-mac-contacts/build/Release/contacts.node]
41: 0x11b7e9544 Napi::details::CallbackData<Napi::Boolean (*)(Napi::CallbackInfo const&), Napi::Boolean>::Wrapper(napi_env__*, napi_callback_info__*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/node-mac-contacts/build/Release/contacts.node]
42: 0x115da121a napi_create_function [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
43: 0x110c76f1f v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
44: 0x110c76441 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
45: 0x110c75ad2 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Name>, void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyCallbackInfo<v8::Boolean> const&)) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
46: 0x1116a8878 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer)[22797]: ../../third_party/electron_node/src/node_api.cc:1064:napi_status napi_call_threadsafe_function(napi_threadsafe_function, void *, napi_threadsafe_function_call_mode): Assertion `(func) != nullptr' failed.
 1: 0x114da9135 node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x114da8ebf node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x114d85283 napi_call_threadsafe_function [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x11b32f897 invocation function for block in SetupListener(Napi::CallbackInfo const&) [/Users/kishan/Dropbox/Kishan/foo/node_modules/node-mac-contacts/build/Release/contacts.node]
 5: 0x7fff35262864 -[__NSObserver _doit:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
 6: 0x7fff32bf09cf __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 7: 0x7fff32bf0963 ___CFXRegistrationPost1_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 8: 0x7fff32bf08d8 _CFXRegistrationPost1 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 9: 0x7fff32bf0544 ___CFXNotificationPost_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
10: 0x7fff32bc06bd -[_CFXNotificationRegistrar find:object:observer:enumerator:] [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
11: 0x7fff32bbfb69 _CFXNotificationPost [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
12: 0x7fff35236866 -[NSNotificationCenter postNotificationName:object:userInfo:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
13: 0x7fff31f7aa8e __131-[CNChangesNotifierProxy receiveNotificationName:fromSender:saveIdentifier:userInfo:calledFromNotifierQueue:isFromExternalProcess:]_block_invoke_3 [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
14: 0x7fff6cd62ba8 os_activity_apply_f [/usr/lib/system/libsystem_trace.dylib]
15: 0x7fff31fb785d -[_CNContactsLogger postingNotification:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
16: 0x7fff31f7aa07 __131-[CNChangesNotifierProxy receiveNotificationName:fromSender:saveIdentifier:userInfo:calledFromNotifierQueue:isFromExternalProcess:]_block_invoke_2 [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
17: 0x7fff31f7a509 -[CNChangesNotifierProxy receiveNotificationName:fromSender:saveIdentifier:userInfo:calledFromNotifierQueue:isFromExternalProcess:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
18: 0x7fff31f7a231 __58-[CNChangesNotifierProxy receiveExternalNotificationName:]_block_invoke [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
19: 0x7fff49c44bba -[_CNMainThreadScheduler performBlock:qualityOfService:] [/System/Library/PrivateFrameworks/ContactsFoundation.framework/Versions/A/ContactsFoundation]
20: 0x7fff49c6b7b2 -[CNCoalescingTimer nts_letSomeoneIn] [/System/Library/PrivateFrameworks/ContactsFoundation.framework/Versions/A/ContactsFoundation]
21: 0x7fff49c3d0b0 CNRunWithLock [/System/Library/PrivateFrameworks/ContactsFoundation.framework/Versions/A/ContactsFoundation]
22: 0x7fff49c6b69e -[CNCoalescingTimer handleEvent] [/System/Library/PrivateFrameworks/ContactsFoundation.framework/Versions/A/ContactsFoundation]
23: 0x7fff31f7a17a -[CNChangesNotifierProxy receiveExternalNotificationName:] [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
24: 0x7fff31f7af75 CNChangesNotifierCFNotificationCenterCallback [/System/Library/Frameworks/Contacts.framework/Versions/A/Contacts]
25: 0x7fff32bf09cf __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
26: 0x7fff32bf0963 ___CFXRegistrationPost1_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
27: 0x7fff6cae76c4 _dispatch_call_block_and_release [/usr/lib/system/libdispatch.dylib]
28: 0x7fff6cae8658 _dispatch_client_callout [/usr/lib/system/libdispatch.dylib]
29: 0x7fff6caf3cab _dispatch_main_queue_callback_4CF [/usr/lib/system/libdispatch.dylib]
30: 0x7fff32c3a041 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
31: 0x7fff32bf9e47 __CFRunLoopRun [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
32: 0x7fff32bf8ffe CFRunLoopRunSpecific [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
33: 0x7fff3528d2a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
34: 0x111682e51 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
35: 0x111681bb2 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
36: 0x1116324f3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
37: 0x11160a3f3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
38: 0x114b82a89 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
39: 0x11087c489 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
40: 0x112dfcbd8 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
41: 0x10fafd4f4 ElectronInitializeICUandStartNode [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
42: 0x10edd5794 ElectronMain [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
43: 0x10ed928a5  [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer)]
44: 0x7fff6cb41cc9 start [/usr/lib/system/libdyld.dylib]
45: 0x15

process.versions:

ares: "1.15.0"
brotli: "1.0.7"
chrome: "83.0.4103.24"
electron: "9.0.0-beta.19"
http_parser: "2.8.0"
icu: "65.1"
llhttp: "2.0.1"
modules: "80"
napi: "5"
nghttp2: "1.40.0"
node: "12.14.1"
openssl: "1.1.0"
unicode: "12.1"
uv: "1.33.1"
v8: "8.3.110.5-electron.0"
zlib: "1.2.11"
@codebytere
Copy link
Owner

Oh that's fun - i'll try to dig into it. This may in fact be a bug with Napi itself 🤔

@codebytere
Copy link
Owner

codebytere commented Apr 27, 2020

@KishanBagaria what listener-related code is being invoked there? knowing whether this is happening during setup, teardown, etc will help me narrow this down a bit. Looks like SetupListener at first glance, but there's probably some other stuff going on too.

@KishanBagaria
Copy link
Contributor Author

KishanBagaria commented Apr 27, 2020

I have something like this running in my renderer process:

import nmc from 'node-mac-contacts'
import { throttle } from 'lodash'

if (!nmc.listener.isListening()) nmc.listener.setup()
nmc.listener.on('contact-changed', throttle(() => {
  console.log(new Date(), 'refetching contacts')
  processAllContacts()
}, 5000, { trailing: true }))

And say when I add a contact using the addNewContact() function or delete a contact manually in Contacts.app, that triggers the listener and it crashes with the error in the OP.

@KishanBagaria
Copy link
Contributor Author

Another recent crash log if it's helpful:

/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer)[11902]: ../../third_party/electron_node/src/node_api.cc:1064:napi_status napi_call_threadsafe_function(napi_threadsafe_function, void *, napi_threadsafe_function_call_mode): Assertion `(func) != nullptr' failed.
 1: 0x10a7e5eb5 node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x10a7e5c3f node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x10a7c2003 napi_call_threadsafe_function [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x110d6e86b invocation function for block in SetupListener(Napi::CallbackInfo const&) [/Users/kishan/Dropbox/Kishan/foo/node_modules/node-mac-contacts/build/Release/contacts.node]
 5: 0x7fff32691864 -[__NSObserver _doit:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
 6: 0x7fff3001f9cf __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 7: 0x7fff3001f963 ___CFXRegistrationPost1_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 8: 0x7fff3001f8d8 _CFXRegistrationPost1 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
 9: 0x7fff3001f544 ___CFXNotificationPost_block_invoke [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
10: 0x7fff2ffef6bd -[_CFXNotificationRegistrar find:object:observer:enumerator:] [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
11: 0x7fff2ffeeb69 _CFXNotificationPost [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
12: 0x7fff32665866 -[NSNotificationCenter postNotificationName:object:userInfo:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
13: 0x7fff429cfd5b __61-[ABAccountRepository postDidChangeNotificationWithAccounts:]_block_invoke [/System/Library/PrivateFrameworks/AddressBookCore.framework/Versions/A/AddressBookCore]
14: 0x7fff30029bac __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
15: 0x7fff30029af4 __CFRunLoopDoBlocks [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
16: 0x7fff30028fed __CFRunLoopRun [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
17: 0x7fff30027ffe CFRunLoopRunSpecific [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
18: 0x7fff326bc2a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] [/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation]
19: 0x1070baa01 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
20: 0x1070b9762 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
21: 0x10706a123 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
22: 0x107041533 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
23: 0x10a5bbd79 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
24: 0x1062b2dd9 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
25: 0x108835778 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
26: 0x105533eb4 ElectronInitializeICUandStartNode [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
27: 0x10480a0d4 ElectronMain [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
28: 0x1047c38a5  [/Users/kishan/Dropbox/Kishan/foo/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer)]
29: 0x7fff69f70cc9 start [/usr/lib/system/libdyld.dylib]
[0519/231030.170085:WARNING:system_snapshot_mac.cc(42)] sysctlbyname kern.nx: No such file or directory (2)

sysctlbyname kern.nx: No such file or directory seems to have a bunch of results on Google.

@KishanBagaria
Copy link
Contributor Author

KishanBagaria commented May 24, 2020

For posterity, here's the workaround I used for this. I wrote some Swift code that prints "changed" when the contacts are changed and compiled it into an executable binary. Then in the renderer process I run this binary as a child process.

setbuf(__stdoutp, nil) // disables buffering

class Observer: NSObject {
  @objc func contactStoreDidChange() {
    print("changed")
  }
  override init() {
    super.init()
    NotificationCenter.default.addObserver(
      self,
      selector: #selector(self.contactStoreDidChange),
      name: .CNContactStoreDidChange,
      object: nil
    )
    print("listening")
  }
}
setupListener = () => {
  if (this.isListening) return
  const cp = childProcess.spawn(swiftContactsBinPath)
  cp.stdout.on('data', (chunk: Buffer) => {
    const data = chunk.toString().split('\n')
    if (data.includes('changed')) this.onContactChanged()
  })
  cp.stderr.on('data', chunk => {
    console.error('error', chunk)
  })
  this.isListening = true
}

@codebytere codebytere added the bug Something isn't working label Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants