nativescript-contacts
nativescript-contacts copied to clipboard
Fatal crash in iOS
Referencing this module, as described in the README, is crashing in iOS 13.4. This appears to be related to the availability of CNContactPickerViewController
at runtime.
$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.1 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.
Section that caught my attention:
Error: Class "CNContactPickerViewController" referenced by type encoding not found at runtime.
Full stack trace:
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: Checking for updates to the bundle with hmr hash 6561b1f228d2f1473cf5.
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: The following modules were updated:
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ../node_modules/nativescript-contacts/index.js
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/social/local-contacts.service.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/social/social.effects.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/social/social.module.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/create-account/create-account.module.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/app-routing.module.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: ↻ ./app/app.module.ts
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: Successfully applied update with hmr hash 6561b1f228d2f1473cf5. App is up to date.
CONSOLE LOG file: node_modules/@angular/core/fesm5/core.js:25638:0: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1 0x10643360e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2 0x106482f76 -[TNSRuntimeInspector reportFatalError:]
3 0x105d1725b TNSInspectorUncaughtExceptionHandler
4 0x7fff23e3e12d __handleUncaughtException
5 0x7fff50b3bc05 _objc_terminate()
6 0x7fff4f986c87 std::__terminate(void (*)())
7 0x7fff4f98940b __cxa_get_exception_ptr
8 0x7fff4f9893d2 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
9 0x7fff50b3bad6 _objc_exception_destructor(void*)
10 0x10648a0f0 NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, bool)
11 0x10648abe9 NativeScript::TypeFactory::parseTypes(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, int, bool)
12 0x10646f942 NativeScript::ObjCMethodWrapper::finishCreation(JSC::VM&, NativeScript::GlobalObject*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
13 0x10645911a NativeScript::ObjCMethodWrapper::create(JSC::VM&, NativeScript::GlobalObject*, JSC::Structure*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
14 0x106471c68 NativeScript::overrideObjcMethodCalls(JSC::ExecState*, JSC::JSObject*, JSC::PropertyName, JSC::JSCell*, Metadata::BaseClassMeta const*, Metadata::MemberType, objc_class*, WTF::Vector<Metadata::ProtocolMeta const*, 0ul, WTF::CrashOnOverflow, 16ul> const&)
15 0x10645efc1 NativeScript::ObjCClassBuilder::addInstanceMethod(JSC::ExecState*, JSC::Identifier const&, JSC::JSCell*)
16 0x106464fd0 NativeScript::ObjCClassBuilder::addInstanceMembers(JSC::ExecState*, JSC::JSObject*, JSC::JSValue)
17 0x106469274 NativeScript::ObjCExtendFunction(JSC::ExecState*)
18 0x420119e0116b
19 0x106e6af7f llint_entry
20 0x420119e1f80e
21 0x42011a118b61
22 0x106e6af7f llint_entry
23 0x420119e1f80e
24 0x42011a118b61
25 0x106e6af7f llint_entry
26 0x420119e1f80e
27 0x42011a118b61
28 0x106e6af7f llint_entry
29 0x420119e1f80e
30 0x42011a118b61
31 0x106e6af7f llint_entry
JavaScript stack trace:
extend(file: node_modules/nativescript-contacts/index.ios.js:6:0)
at ../node_modules/nativescript-contacts/index.js(file: node_modules/nativescript-contacts/index.ios.js:6:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/local-contacts.service.ts(file: src/app/social/local-contacts.service.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/social.effects.ts(file: src/app/social/social.effects.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/social.module.ts(file: src/app/social/social.module.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/create-account/create-account.module.ts(file: src/app/create-account/create-account.module.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at fn([native code])
at onInvoke(file: node_modules/@angular/core/fesm5/core.js:26256:0)
at file: node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:138:0
at file:///app/vendor<…>
JavaScript error:
file: node_modules/nativescript-contacts/index.ios.js:6:0: JS ERROR Error: Class "CNContactPickerViewController" referenced by type encoding not found at runtime.
NativeScript caught signal 6.
Native Stack:
1 0x106484251 sig_handler(int)
2 0x7fff51b965fd _sigtramp
3 0x7fff51a8ac19 itoa64
4 0x7fff51a8685c abort
5 0x7fff4f987858 abort_message
6 0x7fff4f986cad std::__terminate(void (*)())
7 0x7fff4f98940b __cxa_get_exception_ptr
8 0x7fff4f9893d2 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
9 0x7fff50b3bad6 _objc_exception_destructor(void*)
10 0x10648a0f0 NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, bool)
11 0x10648abe9 NativeScript::TypeFactory::parseTypes(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, int, bool)
12 0x10646f942 NativeScript::ObjCMethodWrapper::finishCreation(JSC::VM&, NativeScript::GlobalObject*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
13 0x10645911a NativeScript::ObjCMethodWrapper::create(JSC::VM&, NativeScript::GlobalObject*, JSC::Structure*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
14 0x106471c68 NativeScript::overrideObjcMethodCalls(JSC::ExecState*, JSC::JSObject*, JSC::PropertyName, JSC::JSCell*, Metadata::BaseClassMeta const*, Metadata::MemberType, objc_class*, WTF::Vector<Metadata::ProtocolMeta const*, 0ul, WTF::CrashOnOverflow, 16ul> const&)
15 0x10645efc1 NativeScript::ObjCClassBuilder::addInstanceMethod(JSC::ExecState*, JSC::Identifier const&, JSC::JSCell*)
16 0x106464fd0 NativeScript::ObjCClassBuilder::addInstanceMembers(JSC::ExecState*, JSC::JSObject*, JSC::JSValue)
17 0x106469274 NativeScript::ObjCExtendFunction(JSC::ExecState*)
18 0x420119e0116b
19 0x106e6af7f llint_entry
20 0x420119e1f80e
21 0x42011a118b61
22 0x106e6af7f llint_entry
23 0x420119e1f80e
24 0x42011a118b61
25 0x106e6af7f llint_entry
26 0x420119e1f80e
27 0x42011a118b61
28 0x106e6af7f llint_entry
29 0x420119e1f80e
30 0x42011a118b61
31 0x106e6af7f llint_entry
JS Stack:
extend([native code])
at ../node_modules/nativescript-contacts/index.js(file: node_modules/nativescript-contacts/index.ios.js:6:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/local-contacts.service.ts(file: src/app/social/local-contacts.service.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/social.effects.ts(file: src/app/social/social.effects.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/social/social.module.ts(file: src/app/social/social.module.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at ./app/create-account/create-account.module.ts(file: src/app/create-account/create-account.module.ts:1:0)
at __webpack_require__(file: src/webpack/bootstrap:750:0)
at fn(file: src/webpack/bootstrap:120:0)
at fn([native code])
at onInvoke(file: node_modules/@angular/core/fesm5/core.js:26256:0)
at file: node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:138:0
at file: node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:883:0
at onInvokeTask(file:///app/vendo<…>
I'm seeing the same problem. All you have to do is create a new project, add the nativescript-contacts plugin, then add const contacts = require("nativescript-contacts");
and you'll see the error. You don't actually have to invoke anything.
We're using import * as NativeScriptContacts from "nativescript-contacts";
and it works fine with iOS 13.4.x. Maybe you could try that?
Mine is a javascript project, so I use
const contacts = require("nativescript-contacts");
which is functionally equivalent, yes?
I've spent some time investigating this, and error is triggered by line 6 in index.ios.js, which defines the CustomCNContactPickerViewControllerDelegate
function. All the documentation I can find is for swift, not javascript, so I'm not sure if the functions defined within the delegate actually match the protocol. Right now I'm guessing that's where the problem is.
We're using
import * as NativeScriptContacts from "nativescript-contacts";
and it works fine with iOS 13.4.x. Maybe you could try that?
@mrpaaske I am importing it in the same way. I wonder if it is related to an actual device vs. an emulator. We are using emulators for development and that’s where we are hitting the exception. Are you having success when running your application on an emulator?
Hm, strange. I just tried our app on iPhone 11 iOS 13.4.1 (emulator) and with iPhone X iOS 13.4.1 (real device). Both works fine.
Did you upgrade NativeScript or the plugin recently? If so, I recommend to do rm -rf node_modules platforms hooks
, and then npm i
and tns run ios
. It usually helps on some weird issues :)
@mrpaaske Actually, my primary app works OK, too. I had created a sample app to debug another problem when I hit this. It's very easy to recreate:
tns create sampleApp
(create a JavaScript, Hello World app)
tns plugin add nativescript-contacts
add code to invoke contacts.getContact
tns run ios
Yes, I get the same issue with the sample app. I have no idea why this happens...
In your main projects are you referencing or configuring other iOS APIs? What is the tns-ios
version in your main projects?
Nothing more than whatever the {N} javascript hello-world template does. My versions are:
✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.1 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.
I'm getting the same issue with the sample app.
Having the same issue in my project on iPhone 11 Pro Max iOS 13.4.1 (Emulator) and on iPhone 6 iOS 12.4.6
Also seeing this on iOS 13.5.1 on physical iPhone.
I noticed that it fails when running the app via tns run ios --emulator
. However, opening Xcode and running it manually from there works fine..
A colleague found that commenting out the delegate methods makes it possible to run the app with tns run ios
. Obviously getContact()
will not work as intended anymore..
var CustomCNContactPickerViewControllerDelegate = NSObject.extend(
{
initWithResolveReject: function(resolve, reject) {
var self = this.super.init();
if (self) {
this.resolve = resolve;
this.reject = reject;
}
return self;
},
// contactPickerDidCancel: function(controller) {
// this.resolve({
// data: null,
// response: "cancelled"
// });
// },
// contactPickerDidSelectContact: function(controller, contact) {
// controller.dismissModalViewControllerAnimated(true);
//
// //Convert the native contact object
// var contactModel = new Contact();
// contactModel.initializeFromNative(contact);
//
// this.resolve({
// data: contactModel,
// response: "selected"
// });
// CFRelease(controller.delegate);
// }
},
{
protocols: [CNContactPickerDelegate]
}
);
@firescript, do you have any input on this? Are you able to reproduce this issue?
Created a sample app now (Angular+TypeScript), and still seeing this issue on latest versions. Both on emulator (iPhone 11, iOS 13.6) and device (iPhone X, iOS 14 beta 3).
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.7.8 version and is up to date.
✔ Component tns-core-modules has 6.5.12 version and is up to date.
✔ Component tns-android has 6.5.3 version and is up to date.
✔ Component tns-ios has 6.5.2 version and is up to date.
I'm running into this after upgrading my iOS platform from 6.1.2 to 6.5.2. I upgraded the platform in the first place to get my app working on iOS 14. Perhaps a bug was introduced in tns-ios somewhere between those versions?
I can confirm, at least in my app, that this crash happens in iOS runtime 6.3.0 but not 6.2.0. I haven't yet been able to identify why.
I have same issue on real iPhone 12 OS 15.2.1 and simulator iOS 12.1, here is my environment setting.
"nativescript-contacts": "^1.6.4",
"tns-core-modules": "^6.5.27"
"tns-ios": "6.5.2"