This project has moved and is read-only. For the latest updates, please go here.

Unity ios error...

Oct 8, 2012 at 12:51 PM

Hello,

i am trying to use ZXing.net on Unity iphone/ipad build, but when i try to run it on my Ipad, i get an "EXC BAD ACCESS" Error in XCode. It compiles, but QR-Code-Detection is not working, in Unity Editor or Standalone build everything works fine. Am i doing something wrong, or any ideas on how to get it running?

Thanks in advance,Simon

Oct 8, 2012 at 7:22 PM

Hi Simon, sorry I can't help you directly. I don't have a development environment for iOS. Is there any way that I can emulate it on my windows machine?

I look a little bit around. The error "EXC BAD ACCESS" looks like NullReferenceException. Some kind of debugging is needed.
http://answers.unity3d.com/questions/214070/cannot-start-game-on-ipad-exc-bad-access.html
http://answers.unity3d.com/questions/42582/exc-bad-access-in-xcode-but-runs-fine-in-unity-iph.html

Oct 9, 2012 at 7:45 AM

Thanks for your answer! This is the Log of XCode i get, unfortunately i'm not really into XCode/ObjC/Apple-Stuff... :

ZXing_QrCode_Internal_FinderPatternFinder_find_System_Collections_Generic_IDictionary_2_ZXing_DecodeHintType_object + 104
0x8e4094:  mov    r0, #0
0x8e4098:  str    r0, [r11, #32]
0x8e409c:  ldr    r0, [r11, #32]
0x8e40a0:  strb   r0, [r11]
0x8e40a4:  ldr    r1, [r11, #36]
0x8e40a8:  ldr    r0, [r1, #8]
0x8e40ac:  mov    r2, r0
0x8e40b0:  ldr    lr, [r2]  => Thread 17: EXC_BAD_ACCESS (code=1, adress=0x0)   => This is the line that gives me the error.

Unfortunately there is now way to emulate this on windows. My next question would be: How can i use ZXing.net source Files in Unity instead of the dll? Perhaps when i don't use the dll debugging will be a bit more helpful than it is now. But first I will try to compile a clean scene with just your dll in it, perhaps the error resolves from any other of my scripts, i will try asap.

Thanks,

Simon

Oct 9, 2012 at 9:07 AM

ok, so i checked it: The Error occures, whenever i call the "Decode" Method of the BarcodeReader Class. Is there any possibility to edit or view the Class inside of the dll, respectivly is there a way to get the Unity-Source files unpacked (not inside DLL)?

Greetings, Simon

Oct 9, 2012 at 7:44 PM

What version of ZXing.Net do you use? Current 0.9?

You can get the source from the repository or from the download page.
With the source you can build your own version of the dll.

The error occurs in the method
ZXing.QrCode.Internal.FinderPatternFinder::find

But I don't know what should be wrong with it.

You can try to scan another barcode type first. The error occurs within the QR Code decoder. Perhaps the other formats work.
So try a PDF417 or EAN barcode and initialize the BarcodeReader with PossibleFormats = new List<BarcodeFormat>{ BarcodeFormat.EAN_8, BarcodeFormat.PDF_417 };

The source code of ZXing.Net can be used directly with Unity I think. Put the source in a sub directory in the assets.
But I didn't try that out.

Oct 10, 2012 at 7:26 AM

I'm using current 0.9. I found the source, thanks, but also can't find any problems whitihin the error-producing method - i'll try the other readers, in fact i just need EAN barcode, so when this one would work i'd be happy. I also tried to use the Source directly (without dll) in Unity, problem is that Unity doesn't seem to support namespaces and gives me several errors because of identical script-names. As soon as i get something working (if i do so :) ) i'll post them here!

Oct 10, 2012 at 8:18 PM

Ok, than you should try it with the following code snippet (short version of the unity demo in the source code repo)

   void Start()
   {
      camTexture = new WebCamTexture();
      OnEnable();
   }

   void Update()
   {
      c = camTexture.GetPixels32();
   }

      var barcodeReader = new BarcodeReader();
      barcodeReader.PossibleFormats = new List<BarcodeFormat>();
      barcodeReader.PossibleFormats.Add(BarcodeFormat.EAN_8);
      barcodeReader.PossibleFormats.Add(BarcodeFormat.EAN_13);
      var result = barcodeReader.Decode(c, W, H);

Using the source code of ZXing.Net directly should be possible. I have one solution for testing purposes with the sources. The files are in located in the directory Assets\Plugins\ZXing.

Oct 11, 2012 at 7:45 AM

Hi,

i found the problem - it is because the Unity Webcamtexture returns a size of 16x16 on the ipad (the texture shows properly, its just returns the wrong sizze when calling webcamtexture.with or height), and so the "W" and "H" paramters i hand over to the BarcodeReader are not right. I tried to hard code the values (found out that the ipad-camera returns 1280*720 Webcamtexture), but had no luck with this yet. But i'm sure i'll get it working, now that i fiund the problem. Thanks for all your help!

Greetings, Simon

Oct 12, 2012 at 8:12 PM

It would be great if you can post here your solution for the error when you find it.