-
Notifications
You must be signed in to change notification settings - Fork 1.4k
iOS WebThreadLock crash on barcodeScanFailed #310
Comments
I am happy to report that I appear to have fixed the problem! I simply replaced this code in CDVBarcodeScanner.mm
with
I confirmed that when barcodeScanFailed is called now (which it still is sometimes, but that's a different issue), it is still in the same secondary thread as the capture session, but its call of barcodeScanDone now takes place in the main thread, as do all succeeding calls to the orientation-related view methods. So now the scan failure is just handled normally, not by crashing. |
@JohnBrooking That's great news! Are you up for a little PR with that change? |
Sure, if you agree that it's correct. |
I do, it makes a lot of sense to me. That and the fact you no longer see the crash 😉 |
@JohnBrooking @EddyVerbruggen I didn't see the JohnBrooking's PR nor the closed PR's |
@JohnBrooking thanks John, I see you never sent a PR so I added it into the plugin for you. |
Thanks, guys. Sorry I dropped it. I'm new to Github/open source, and I didn't know "PR" meant I was supposed to do something. 😊 |
No problem @JohnBrooking. The nice thing about open source is if you find a bug you can always send a pull request. |
This thread has been automatically locked. |
I recently upgraded to 6.0.1 from a much older version (~2013), and have begun experiencing an occasional crash on iPhone, especially when scanning in landscape mode.
I think I may have figured it out, but I'm pretty new to iOS and mobile programming, and am only reading about dispatch queues this morning! (I did not write the app I'm working on, just modifying it.)
The debugger message is
The top section of the call stack is
The actual line that's crashing is in source file CDFVViewController.m, on the line where res is set to the result of the webView.stringByEvaluatingJavaScriptFromString method (last line of this snippet):
To help debug, I put in logging statements at the begin and end of all of the orientation-related methods, as well as "captureOutput", and noticed this interesting thing:
All prior calls to CDVViewController.shouldAutorotateToInterfaceOrientation take place on thread 1225939, with the statement "Inside captureOutput" taking place on various other threads. But notice that the call to CDVViewController.shouldAutorotateToInterfaceOrientation which fails occurs on thread 1225972, the same thread as the last "Inside captureOutput" statement!
I'm assuming 1225939 is the main thread, and captureOutput gets called in a secondary thread. I see in CDVbcsProcessor.setupCaptureSession:
Then I see in CDVbcsProcessor.barcodeScanSucceeded:
But CDVbcsProcessor.barcodeScanFailed does not dispatch back to the main thread:
I feel like this is the problem, and I'm going to test that now. I'll update this note after I see what that does.
The text was updated successfully, but these errors were encountered: