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

Cannot read property 'getCodewords' of null #318

Open
hristijankiko opened this issue Jun 18, 2020 · 20 comments
Open

Cannot read property 'getCodewords' of null #318

hristijankiko opened this issue Jun 18, 2020 · 20 comments
Labels

Comments

@hristijankiko
Copy link

hristijankiko commented Jun 18, 2020

Describe the bug
PDF417 reader throws the error below sometimes (I would say 50% chance) when barcode gets presented to the camera.

To Reproduce
Steps to reproduce the behavior:

  1. Launch reader
  2. Present barcode

Expected behavior
It should not throw a TypeError exception when barcode is presented.

Screenshots
Code used:
image

Error:
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Microsoft Edge (Happens in Chrome as well)
  • Version 85.0.545.0 (Official build) dev (64-bit)
@odahcam
Copy link
Member

odahcam commented Jun 24, 2020

Thanks for the very well wirtten issue. This is related to #295 and #280.

@iojancode
Copy link

Similar issue here, not sure its the same:

PDF417 reader throws always the following error: null is not an object (evaluating 'this.detectionResultColumns[t-1].getCodewords') when barcode is presented, it happens 100% of the time

@zacharytyhacz
Copy link

zacharytyhacz commented Aug 15, 2020

Getting same issue too on Chrome and latest @zxing/library version.

Cannot read property 'getCodewords' of null

@odahcam
I see there's recent commits, any progress on this particular issue?

image

@zacharytyhacz
Copy link

Can also confirm for:

Device: Iphone7 IOS 13.3.1
Browser: Safari

image

@odahcam
Copy link
Member

odahcam commented Aug 18, 2020

I see there's recent commits, any progress on this particular issue?

No, I was finishing the text-encoding project, so no progress in here. My next goal is to implement E2E tests for the browser layer, so we should be able to spot and fix these kind of issues.

I'm a little rusty and really do not have time to debug PDF417 now, so unless there isn't possible, I would suggest some workaround. Sorry guys.

Also, just to give some context, it doesn't happen with every PDF417 type, but it seems just in one. There's in fact a piece of decoding that is not implemented in the codebase because we couldn't port the entire code at the time the module was ported from Java. Now I believe it should be a lot easier (as contributors and I fixed a lot of stuff, created similar code in other parts of the project), so if anyone wants to take a shot, just open a PR and ping me.

@zacharytyhacz
Copy link

I see there's recent commits, any progress on this particular issue?

No, I was finishing the text-encoding project, so no progress in here. My next goal is to implement E2E tests for the browser layer, so we should be able to spot and fix these kind of issues.

I'm a little rusty and really do not have time to debug PDF417 now, so unless there isn't possible, I would suggest some workaround. Sorry guys.

Also, just to give some context, it doesn't happen with every PDF417 type, but it seems just in one. There's in fact a piece of decoding that is not implemented in the codebase because we couldn't port the entire code at the time the module was ported from Java. Now I believe it should be a lot easier (as contributors and I fixed a lot of stuff, created similar code in other parts of the project), so if anyone wants to take a shot, just open a PR and ping me.

All good, E2E tests would point everything in the right direction and help a ton.

I'll create a mininal reproduced project very soon and provide some sample PDF 417 barcodes ( sample ID cards ) that work consistently and ones that throw this error ( I have a sample barcode that throws the error, both on the video scanning method and decodeFromImage method ) so we can narrow down whats going and go from there.

@zacharytyhacz
Copy link

zacharytyhacz commented Aug 21, 2020

@odahcam Hey yall, i recreated a simple project that recreates the issue here: https://github.com/zacharytyhacz/zxing-pdf417-bug

Also here's some sample codes that are in my test repo that we all can use to test things:

This one consistently fails on an image upload to scan decodeFromImage() and decodeOnceFromVideoDevice()
image

This one is 50/50 if it fails or successfully scans decodeFromImage() and decodeOnceFromVideoDevice() ( this one is slightly blurry/low quality )
image

And no data get's found in this one, from both decodeFromImage() and decodeOnceFromVideoDevice()
image

@boxidilshan
Copy link

boxidilshan commented Aug 21, 2020

I am also getting the same issue. Any workarounds to resolve this?

@bradens
Copy link

bradens commented Sep 10, 2020

Also running into the same issue, getting noCodeWords and ChecksumException popping up a lot. Digging into the detector code that's throwing it's in the detector when trying to find the left/right alignment.

@bradens
Copy link

bradens commented Sep 10, 2020

@zacharytyhacz did you end up solving the issue with those cards?

@boxidilshan
Copy link

It is a simple fix in DetectionResult.ts in core/pdf417/decoder. You have to add null checks in 2-3 places. Tried to merge that but I have lot of changes from the day I changed. Not sure whether this is fixed already. I could get it to work after fixing that.

@zacharytyhacz
Copy link

@bradens Hey there, no I do not have a work around at the moment.

@boxidilshan You are correct about that "fix", but if you test adding a null check, the scanning gets stuck in an endless loop for some images, not good.

@bradens
Copy link

bradens commented Sep 23, 2020

I did a little bit more digging and it seemed to be problems with the error correction algorithm, testing against the zxing jarfile though, it seemed like it was having problems with the same images. I was able to fix my case by getting higher quality images, which I know isn't a great fix. :|

@odahcam
Copy link
Member

odahcam commented Oct 21, 2020

@boxidilshan do you still have the code with the fixes you made?

@DarrenWainwright
Copy link

@boxidilshan - would it be possible to post where these 'fixes' can be applied?

Trying to get a POC together and this is killing me.. cheers

@jakubsuszynski
Copy link

Hello, any progress on this one? @odahcam

@zacharytyhacz
Copy link

I would like a progress update as well @odahcam

I may look back into the code myself and see if I could make a PR fix, but I am just not familiar with the codebase and adjusting the OCR or whatever it uses to image-parse the data could be complicated ( I've never dealt with stuff like this, thats why Im using this library )

@odahcam
Copy link
Member

odahcam commented May 24, 2021

I injured my right arm and i am unable to contribute on the library for the past 4 weeks plus next 4 weeks. sorry guys, I'm doing everything I can so I heal faster.

@outprove
Copy link

@odahcam Hope your arm healed up!

I'm hitting this same issue as well. I'm not familiar with the code base, so if anyone has any pointers as to where/what the "fixes" are, I'd appreciate it.

@zacharytyhacz
Copy link

hello @outprove , I am planning on taking a look this weekend to hopefully find a fix and create a PR. the code is actually pretty organized and there are tests. If you have a reproduce-able issue project, that will help a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants