I am writing a barcode scanner for iOS and Android using Flex Mobile and ZXing. I have optimized ZXing as much as I can, but it is still too slow to use for continual scanning on some older devices. I extracted some of the heavy work into a C SWIG using FlasCC and got some pretty decent speedups during scanning. When testing on an actual device though, I get errors when starting my app. The debug console says "Mutex cannot be initialized" and crashes. Removing calls to my SWC, the app starts just fine. First of all, is using this type of SWC even possible on a mobile device? If so, what am I doing wrong? Also, the size of the generated library is pretty large (400KB+). Is there any way to reduce the size by excluding all the extra fluff?
3 Answers
This is an old question, but in case anyone else encounters this issue:
I had the same problem and the fix was simply recompiling my FlasCC SWC using the latest version of FlasCC (now known as CrossBridge).
I used CrossBridge version 1.0.1 and it did the trick.

- 11
- 1
While you can use FlasCC on mobile, I wouldn't recommend it: your code can run at native speeds and you have access to the OS APIs. Have you looked into Air Native Extensions?

- 6,393
- 11
- 51
- 94
-
What do I need to do to get FlasCC working on mobile? Why wouldn't you recommend it? I have looked into native extensions, but the ZXing library for iOS only scans QR codes at the moment. For the project I am working on, I really need to be able to scan 1D and 2D barcodes. – Colin Nov 02 '12 at 15:58
-
I didn't do anything special to make FlasCC work on mobile. Most likely you're having some other kind of problem. Are you able to run your SWF in the browser? – paleozogt Nov 02 '12 at 19:26
-
I simply created a library with one method call in C, packaged it into a SWC using FlasCC, and included it in my mobile projet. I didn't run the SWF in the browser since it is a mobile project, but it worked great in the AIR mobile simulator with a 5x speedup for that particular method. I'm wondering if it has something to do with how I package it since the error has something to do with the Preloader and Mutexes. – Colin Nov 05 '12 at 17:33
-
I think you should simplify your problem and do a FlasCC 'hello world' and see if that works, then slowly build it back up to your full library. – paleozogt Nov 05 '12 at 17:35
-
I tried that. Created a C method that simply returns an AS String "hello world". Works great in the simulator, crashes on my Galaxy S3 when starting up the app with a "Mutex cannot be initialized" error. – Colin Nov 05 '12 at 18:22
-
I ended up never figuring this out and just spending the time to write native extensions for iOS and Android. Turned out to be much faster and better looking anyway. – Colin Nov 12 '12 at 17:24
AIR for mobile doesn't yet support Flash Workers, which is what the FlasCC multi-threading is based on. Are you trying to run ZXing in a background thread, or are you compiling your FlasCC SWC with "-pthread" ?
[edit] Actually there might be an error in our startup code for AIR mobile, even when the FlasCC code is not threaded... testing a fix now

- 41
- 3
-
I was not using workers or any sort of multithreading. Like I said above, I created a very simple hello world project library and run it from a flex mobile app. Thanks for looking into the issue. – Colin Nov 16 '12 at 20:32