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

AOT compatibility #76

Closed
iwoogy opened this Issue Feb 15, 2017 · 11 comments

Comments

Projects
None yet
4 participants
@iwoogy
Copy link

iwoogy commented Feb 15, 2017

Hello,

I'm switching to AOT compilation on my project including the barcode scanner plugin.

With JIT, the barcode scanner works fine but with AOT compilation, I have this error when the component calling the plugin is initialized :

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1 0x10069f764 NativeScript::FFICallbackNativeScript::ObjCMethodCallback::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2 0x100f292cc ffi_closure_SYSV_inner
3 0x100f2c1b4 .Ldo_closure
4 0x191e67d30
5 0x191e67cb0
6 0x191e52128
7 0x191f83ea0
8 0x19203ced4
9 0x1923f2628
10 0x1923ee6c0
11 0x18bf2a0c0
12 0x18bf27cf0
13 0x18bf28180
14 0x18be562b8 CFRunLoopRunSpecific
15 0x18d90a198 GSEventRunModal
16 0x191e9d7fc
17 0x191e98534 UIApplicationMain
18 0x100f2c044 ffi_call_SYSV
19 0x100f28e0c ffi_call_int
20 0x100f28924 ffi_call
21 0x1006614fc NativeScript::FFICall::call(JSC::ExecState*)
22 0x100c93888 JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*)
23 0x100c9bf08 llint_entry
24 0x100c9bf18 llint_entry
25 0x100c9bf18 llint_entry
26 0x100c9bf18 llint_entry
27 0x100c9bf18 llint_entry
28 0x100c9bf18 llint_entry
29 0x100c9bf18 llint_entry
30 0x100c957f8 vmEntryToJavaScript
31 0x100c35294 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
JavaScript stack trace:
1 __tryOrUnsub@file:///app/vendor.js:9274:22
2 next@file:///app/vendor.js:9219:34
3 _next@file:///app/vendor.js:9172:30
4 next@file:///app/vendor.js:9136:23
5 next@file:///app/vendor.js:19272:29
6 emit@file:///app/vendor.js:34698:80
7 checkStable@file:///app/vendor.js:21549:44
8 onLeave@file:///app/vendor.js:21625:25
9 onInvoke@file:///app/vendor.js:21587:34
10 invoke@file:///app/vendor.js:57183:42
11 run@file:///app/vendor.js:57077:49
12 zonedCallback@file:///app/vendor.js:56004:27
13 notify@file:///app/vendor.js:12823:31
14 onSelectedIndexPropertyChanged@file:///app/vendor.js:43902:20
15 _trySetNativeValue@file:///app/vendor.js:8603:43
16 _onPropertyChanged@file:///app/vendor.js:8566:32
17 _onPropertyChanged@file:///app/vendor.js:79782:49
18 _setValueInternal@file:///app/vendor.js:3215:36
19 _setValue@file:///app/vendor.js:3041:31
20 set@file:///app/vendor.js:83454:27
21 selected@file:///app/vendor.js:43980:18
22 UIApplicationMain@[native code]
23 start@file:///app/vendor.js:16359:26
24 bootstrapApp@file:///app/vendor.js:55618:28
25 bootstrapModuleFactory@file:///app/vendor.js:55599:26
26 @file:///app/bundle.js:77839:139
27 webpack_require@file:///app/vendor.js:53:34
28 webpackJsonpCallback@file:///app/vendor.js:25:42
29 anonymous@file:///app/bundle.js:2:13
30 evaluate@[native code]
31 moduleEvaluation@[native code]
32 @[native code]
33 promiseReactionJob@[native code]
34 require@[native code]
35 anonymous@file:///app/starter.js:2:8
36 evaluate@[native code]
37 moduleEvaluation@[native code]
38 @[native code]
39 promiseReactionJob@[native code]
JavaScript error:
file:///app/vendor.js:9274:22: JS ERROR Error: Token must be defined!

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start-ios-bundle"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ start-ios-bundle: tns run ios --bundle --disable-npm-install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start-ios-bundle script 'tns run ios --bundle --disable-npm-install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tns run ios --bundle --disable-npm-install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/dev/Documents/dev/myclap/clients/mobile_clapeur/npm-debug.log

Can you help me figure out how to do ?

Thanks

Bobby

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Feb 15, 2017

I have no clue, nor does the stacktrace provide any. Perhaps someone else?

@hypery2k

This comment has been minimized.

Copy link

hypery2k commented Mar 21, 2017

Getting this issue:

03-21 10:00:37.571 10083 10083 I ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
03-21 10:00:37.746 10083 10083 E JS      : EXCEPTION: Uncaught (in promise): TypeError: __WEBPACK_IMPORTED_MODULE_65_nativescript_barcodescanner_barcodescanner_common__.BarcodeScanner is not a constructor
03-21 10:00:37.746 10083 10083 E JS      : ORIGINAL STACKTRACE:
03-21 10:00:37.746 10083 10083 E JS      : Error: Uncaught (in promise): TypeError: __WEBPACK_IMPORTED_MODULE_65_nativescript_barcodescanner_barcodescanner_common__.BarcodeScanner is not a constructor
03-21 10:00:37.746 10083 10083 E JS      :     at resolvePromise (file:///data/data/de.sample.myapp.app/files/app/vendor.js:59106:31)
03-21 10:00:37.746 10083 10083 E JS      :     at resolvePromise (file:///data/data/de.sample.myapp.app/files/app/vendor.js:59091:17)
03-21 10:00:37.746 10083 10083 E JS      :     at file:///data/data/de.sample.myapp.app/files/app/vendor.js:59139:17
03-21 10:00:37.746 10083 10083 E JS      :     at ZoneDelegate.module.exports.ZoneDelegate.invokeTask (file:///data/data/de.sample.myapp.app/files/app/vendor.js:58913:37)
03-21 10:00:37.746 10083 10083 E JS      :     at Object.onInvokeTask (file:///data/data/de.sample.myapp.app/files/app/vendor.js:12924:37)
03-21 10:00:37.746 10083 10083 E JS      :     at ZoneDelegate.module.exports.ZoneDelegate.invokeTask (file:///data/data/de.sample.myapp.app/files/app/vendor.js:58912:42)
03-21 10:00:37.746 10083 10083 E JS      :     at Zone.module.exports.Zone.runTask (file:///data/data/de.sample.myapp.app/files/app/vendor.js:58813:47)
03-21 10:00:37.746 10083 10083 E JS      :     at drainMicroTaskQueue (file:///data/data/de.sample.myapp.app/files/app/vendor.js:59045:35)
03-21 10:00:37.751 10083 10083 E JS      : Unhandled Promise rejection: __WEBPACK_IMPORTED_MODULE_65_nativescript_barcodescanner_barcodescanner_common__.BarcodeScanner is not a constructor ; Zone: angular ; Task: Promise.then ; Value: TypeError: __WEBPACK_IMPORTED_MODULE_65_nativescript_barcodescanner_barcodescanner_common__.BarcodeScanner is not a constructor TypeError: __WEBPACK_IMPORTED_MODULE_65_nativescript_barcodescanner_barcodescanner_common__.BarcodeScanner is not a constructor
@hypery2k

This comment has been minimized.

Copy link

hypery2k commented Mar 21, 2017

@iwoogy you can try this:

export function createBarcodeScanner() {
  return new BarcodeScanner();
}

      providers: [
        {provide: BarcodeScanner, useFactory: (createBarcodeScanner)},
@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Mar 22, 2017

@hypery2k Thanks for sharing that! Is there (to your knowledge) anything we can fix in the plugin to make this easier for folks?

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented May 16, 2017

Added this to the readme, thx.

@iwoogy

This comment has been minimized.

Copy link
Author

iwoogy commented May 21, 2017

Hello,

I'm so sorry for the delay, I had to attend to other parts of the project for some time.

I tried to add the code suggested by @hypery2k, but I still have an error :

In the meantime, I have upgraded the project to NativeScript 3.0 and Angular 4 hoping that it could help.

Thanks guys for your help !

@tscislo

This comment has been minimized.

Copy link

tscislo commented Oct 1, 2017

Guys! Is there any permanent solution for this?

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Oct 3, 2017

@tscislo I have this plugin in a number of apps that have been Webpack (and all related bits) without problems. Is there a repo I can look at to try and help you?

@tscislo

This comment has been minimized.

Copy link

tscislo commented Oct 10, 2017

@EddyVerbruggen I used solution proposed by @hypery2k and currently it works. However I consider it to be a workaround.

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Oct 10, 2017

Ah, ok. Well, I'm open to suggestions, but I'll try a few things as well.

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Oct 10, 2017

@tscislo Can you give the latest version a spin? And a question: is there a particular reason why you want to use dependency injection instead of doing simply new BarcodeScanner()? It's not that DI will gain you anything in this case IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.