blackberry / WebWorks-Community-APIs

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

BarcodeScanner - library fails to load #305

Closed bryanhiggins closed 10 years ago

bryanhiggins commented 10 years ago

The latest version of the BarcodeScanner Cordova plugin fails to load.

The .so file would not load after commit e61abd1c3b4a984b1496de9c2aa7c9f789696708

Going back to the prior comment (Nov 29), the library loads but no camera UI appears when clicking the button in the sample app.

maxupp commented 10 years ago

Adding to this: I can confirm that the library issue appears when trying to run the sample app. My own app however logs that the app failed to connect to http://localhost:8472/com.blackberry.community.barcodescanner/startRead. I'm not sure if this happens because the library isn't loaded, but it doesn't seem like it.

timwindsor commented 10 years ago

If you use the .so file from the prior commit, but still use the latest sample app, it works for me. I'm still trying to configure the project to get the .so to build properly. The necessary files were never checked in, but I thought I had recreated the project correctly and had it working.

timwindsor commented 10 years ago

Okay, I just got an update from the author who worked on this previously and there were several missing changes in the source that we had published here originally. I've been able to build the library and load it in the sample app now.

Some of the changes may have been enough to cause the problems you were seeing @maxupp , but I'm not certain. Can you give it a try with what we have now?

maxupp commented 10 years ago

I gave it a try, and i'm able to run the sample app now, although the viewfinder seems to have a resolution of about 50x30 with 10 colors... is that the intended beahviour or is this another problem? I still get the couldn't connect to the plugin server in my actual app, but this appears to be a problem with my app then. Thank you for all you've done @timwindsor.

Edit: This is what it looks like: http://i.imgur.com/oXa6k4V.jpg

timwindsor commented 10 years ago

Hmm. That's not right. It definitely has a low resolution normally, but it's higher than that and with normal colour. I feel like I've seen that issue before though. I can't remember what exactly was the problem. A restart or delete and reinstall might fix it.

maxupp commented 10 years ago

I did reinstall, but it still shows up like this in the sample app. I also made an entirely new Cordova project, installed IO and the barcodescanner, and pasted my www and merges folders in the new project, but i still get the connect error there, even though i integrated the entire sample app on a seperate page in it...

Is it possible that i don't have compatible version of com.blackberry.io? I installed the latest one that i could find, from May.

timwindsor commented 10 years ago

I updated my Cordova install to the latest, created a new project, added the blackberry10 platform, added the barcodescanner plugin from the plugin registry (which automatically adds the io plugin), copied in the js, css, and index.html files then built it. I got the same weird image, but it did run otherwise. So I've definitely messed up something in getting my newly built .so files into the registry. I'll investigate that.

However, I'm not sure what could be happening with your own app. Is there anything that could be in the www or merges that could be breaking this?

maxupp commented 10 years ago

IT does indeed add the IO plugin, but my company's firewall prohibits access to the plugin registry, so typically i download the plugins and install them offline. As you said, it does scan barcodes, but it's kind of a guessing game actually hitting them.

I'm sure i messed up somewhere but i have no clue where it could be. The merges folder just contains the scan.js file that i use to encapsulate the different APIs. Is it possible that the plugin doesn't work if it's loaded and executed in a child webview?

timwindsor commented 10 years ago

Yes, that's the cause of it. I've recreated that in my app and now get the same issue you do. I don't think that the childwebview has the same connections set up to do plugin calls. If @bryanhiggins is still following maybe he can confirm that.

Are you doing that just because of the requirement for a canvas?

bryanhiggins commented 10 years ago

That's right. Plugins are not supported within the child webview.

maxupp commented 10 years ago

Well, that kind of kills my whole project. I NEED the ajax pages to work. The way it's currenty set up is that there is a menu html, and an html site for each module of the app. Each module's page contains several ajax pages that i load with jquery. So in order to call the plugin i would have to completely restructure the project. Android has no problems whatsoever with plugins in child browser windows, i don't get why Blackberry i so different?

Is there any way i could get the blackberry webview to load ajax pages in the same window as the parent one? That would also get rid of the header (containing a close button on the page title) that is added in child views.

maxupp commented 10 years ago

Okay, quick update: i got the update to work by replacing the standard links with window.location.href assignments. Maybe i'm stupid but i think it should be made widely know that plugins are not supported in child webviews.

I got the plugin running now, but the resolution is still crappy. @timwindsor Can i expect an update by wednesday? I have a rollout then, in which i would like to include the app.

timwindsor commented 10 years ago

I'll see what I can do before then. I hope it's just a small oversight.

timwindsor commented 10 years ago

What OS version are you running on @maxupp ?

timwindsor commented 10 years ago

Okay, I think I figured it out. The reason I was asking was I was seeing different results on 10.3 vs 10.2.1. The images for the viewfinder were using default values for image quality. That seems to have been low on 10.2.1, but probably about 0 on 10.3, so that's what we were seeing. With these fixes you should see better quality than before, but still decent performance.

maxupp commented 10 years ago

Thank you! It's working for me now :) Performance isn't the best though, but that was expected. I might attempt to improve it by sending captured images directly to the viewfinder and only analyze every 10th frame or so. That should up the framerate to about 30fps.