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

dismissviewcontroller:aimated:completion: in captureresult:result: crashes app #26

Closed
baze opened this issue Dec 6, 2012 · 17 comments
Closed

Comments

@baze
Copy link

baze commented Dec 6, 2012

i started integrating zxingobjc into my app by using the example code and it works well, but I want to dismiss the Scanner view controller when I actually get a result while scanning, so I stop the capture and call dismissviewcontroller:animated:completion, but right after the controller is dismissed, the app crashes.

i get some messages from libobjc.A.dylib`objc_msgSend: which i don't understand, but I guess it might be a threading error. not sure though.

i also tried making sure to dismiss from the main thread, but it didn't help. is this a known issue and do you have any tips for me as how to dismiss the scanner view controller correctly when it got a result?

@baze
Copy link
Author

baze commented Dec 6, 2012

ok, actually it is due to overreleasing zxcapture. when I enable zombie objects, I get this error:

*** -[ZXCapture release]: message sent to deallocated instance 0x22364c10

does zxingobjc not work with ARC projects yet?

@benvium
Copy link

benvium commented Dec 13, 2012

I'm getting the same issue. Unfortunately this is making ZXingObjC of no use to me. It looked very promising too!

@benvium
Copy link

benvium commented Dec 13, 2012

.. ok I believe I've sorted it out, simply by marking my ViewController .m file compiled without ARC. Haven't had any crashes yet..

@rtiago42
Copy link

I got the some problem on an app I'm developing.

I was unable to identify the culprit, but I'm convinced the problem happens during the deallocation. While trying to pin point it, I came to the conclusion (albeit being unable to verify it) that the crash happens on the garbage collector as a cause of over releasing.

**
As a workaround I created a static ZXCapture and re-use it, instead of letting it be dealloced.

@percysnoodle
Copy link

Same here. The crash is in AVFoundation__74-[AVCaptureVideoDataOutput _AVCaptureVideoDataOutput_VideoDataBecameReady]_block_invoke_0: so it looks like there's a AVCaptureVideoDataOutput with the ZXCapture or one of its properties as a delegate that isn't being nilled out in dealloc.

@kilink
Copy link

kilink commented Feb 1, 2013

I found that you need to remove the capture.layer from your view before calling dismissViewControllerAnimated:completion:. Here's what I do when dismissing the view controller:

[self.capture.layer removeFromSuperlayer];
[self.capture stop];
[self dismissViewControllerAnimated:YES completion:nil];

@baze
Copy link
Author

baze commented Feb 1, 2013

Nice, that works fine!
Thank you very much.

On 01.02.2013, at 16:06, Patrick Strawderman notifications@github.com wrote:

I found that you need to remove the capture.layer from your view before calling dismissViewControllerAnimated:completion:. Here's what I do when dismissing the view controller:

[self.capture.layer removeFromSuperlayer];
[self.capture stop];
[self dismissViewControllerAnimated:YES completion:nil];

Reply to this email directly or view it on GitHub.

@christosc
Copy link

Thanks very much! It works!

@BonnieBonfire
Copy link

Thank you.

@aceontech
Copy link

Has this fix been pushed to the Cocoapods version of ZXingObjC, because I'm still encountering this issue when I include ZXing 2.1.0 via Cocoapods? Thanks!

@jxdwinter
Copy link

+1

@Vladlex
Copy link

Vladlex commented Nov 5, 2013

I'm on a 2.2.2 version and this bug still happens (iOS7, iPhone 4).
But "removeFromSuperlayer" works perfectly for me.

@cwalcott cwalcott reopened this Nov 17, 2013
@cwalcott
Copy link
Contributor

Are you seeing the "message sent to deallocated instance" error on [ZXCapture release]?

@zhenja
Copy link

zhenja commented Nov 19, 2013

Same for me, working with version 2.2.2 on iOS 7.0.4 getting this error message:
-[ZXCapture release]: message sent to deallocated instance
But can't reproduce it :(

@cwalcott
Copy link
Contributor

cwalcott commented Mar 7, 2014

I've just pushed (TheLevelUp/ZXingObjC@d9e3d23) a major cleanup to ZXCapture. I hope it will get rid of any remaining memory issues, and if not, at least make them easier to debug.

@cwalcott cwalcott closed this as completed Mar 7, 2014
@davidfrasch
Copy link

I think the Problem is still available with ne newest Version and iOS 7.1. After I scan 1-10x QR-Codes fast behind each other, i getting an EXC_BAD_ACCESS Error. After using Instruments(zombie) I recognize a ZXCapture-Zombie. After implementing the short Code part above:
[self.capture.layer removeFromSuperlayer];
[self.capture stop];

it seems to work fine! Thank you very much!

@lugede
Copy link

lugede commented Dec 10, 2014

Thank u very much.

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

No branches or pull requests