blackberry / WebWorks-Community-APIs

Community owned repository containing JavaScript Extensions for BlackBerry WebWorks
Apache License 2.0
140 stars 204 forks source link

Issues with new Barcode Scanner (v2.0.0) #389

Closed mattgrande closed 9 years ago

mattgrande commented 9 years ago

Hi all (especially @timwindsor, since he seems to be the expert in these things!),

I tried upgrading my Barcode Scanner this morning from v1.0.4 to v2.0.0. I'm really stoked that we won't need to mess around in the DOM anymore, however it doesn't seem to be working for me...

When I try to start running the camera, by calling startRead, I get an error 22, "The camera call failed because of an invalid parameter." The state is Set VF Props.

Any suggestions?

(I'm experiencing the same issue when running the Sample App as well)

mattgrande commented 9 years ago

I'm also noticing that there are two different versions of barcodescanner_ndk.cpp:

  1. https://github.com/blackberry/WebWorks-Community-APIs/blob/master/BB10-Cordova/BarcodeScanner/plugin/src/blackberry10/native/src/barcodescanner_ndk.cpp
  2. https://github.com/blackberry/WebWorks-Community-APIs/blob/master/BB10/BarcodeScanner/NDK_project/src/barcodescanner_ndk.cpp

However they're quite different. Is that part of the problem?

Edit - My apologies, they're in two different sections.

timwindsor commented 9 years ago

I wasn't able to test on all devices or OS versions, so I could easily have messed something up. What device and OS version are you on? I guess it's at least good that it's reporting errors properly.

mattgrande commented 9 years ago

I've attempted on both a Z30 and Q10.

The Z30 is on 10.2.1.3062, and the Q10 is 1.2.1.2102.

arcaderob commented 9 years ago

@mattgrande @timwindsor The Q10 is 10.2.1.2102

timwindsor commented 9 years ago

Thanks - I'll load those builds and see if I can track it down.

mattgrande commented 9 years ago

Okay, I might have tracked down where the issue is coming from (but I'm far from an expert, so please, tell me if I'm way off track).

In barcodescanner_ndk.cpp, in the startRead function, it's looking for the arg to provide the windowGroup (by way of group).

That seems to be passed by way of index.js's startRead function (parsed out through qnx.webplatform.getWebViews()).

Here's where the problem lies, though... My device isn't using that startRead, it's using the startRead in client.js. That one doesn't seem to pass any arguments to the C++ code:

exec(success, failure, _ID, "startRead", null, false);

I tried passing it variables the same way, however qnx isn't defined in there...

Like I said, I could be way off base, but it might be looking into if I'm not completely wrong.

timwindsor commented 9 years ago

That's a reasonable guess, but it's missing some steps in the middle. Client.js calls go through Cordova and end up calling methods in index.js on BlackBerry 10. Other platforms go direct to native code from Cordova, so that's a little different for us. Index.js uses a JavaScript-Native bridge to make calls into C++ when needed. The args that are needed in barcodescanner_ndk.cpp, are passed in from index.js and are only available in that context, not in client.js.

From the error message you are seeing, the failure should be in these lines: https://github.com/blackberry/WebWorks-Community-APIs/blob/master/BB10-Cordova/BarcodeScanner/plugin/src/blackberry10/native/src/barcodescanner_ndk.cpp#L611-L624

I expect that one of those viewfinder properties are not working properly on 10.2.1, and maybe older builds. I may need to modify the window types or something, to make it work.

timwindsor commented 9 years ago

Check out the latest version. The property that was breaking I didn't need apparently. There's no note that it's only introduced in 10.3, or that the default is to create the viewfinder window anyway.

arcaderob commented 9 years ago

@timwindsor Thanks for the help!

mattgrande commented 9 years ago

Yes, thanks for looking into this! I'll have to buy you a beer the next time I'm in Waterloo!