Skip to content

Calling the capture method on ref causes error #36

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

Open
idanlo opened this issue Feb 1, 2020 · 6 comments
Open

Calling the capture method on ref causes error #36

idanlo opened this issue Feb 1, 2020 · 6 comments

Comments

@idanlo
Copy link

idanlo commented Feb 1, 2020

When calling the ref.current.capture() method I get this error:

Exception 'This function must be called on the UIManager queue' was thrown while invoking capture on target RNPdfScannerManager with params (
    767
)

RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
2AFAF864-7F5C-3011-840D-B066E7377AF1
2AFAF864-7F5C-3011-840D-B066E7377AF1
_dispatch_main_queue_callback_4CF
93BD750D-2ECE-3E38-8405-9E46EFE482C6
93BD750D-2ECE-3E38-8405-9E46EFE482C6
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
9059087B-727B-3B45-B672-09E5B03E6020
@mirhat
Copy link

mirhat commented Feb 10, 2020

@idanlo did you solve this issue, I would really appreciate any help!

@idanlo
Copy link
Author

idanlo commented Feb 10, 2020

@mirhat I did not solve this but apparently this only happens in development, in production build the manual capture works. This still needs to be fixed though.

@humphreyja
Copy link

I suspect the issue has something to do with this: https://github.com/Woonivers/react-native-document-scanner/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.java#L27

The question here is "why does this need to be ran like that, rather than just running the view.capture() method directly?".

After all, the capture method will run async and handle all the image processing in the callback method so detecting what thread it's on before calling it is pointless? Am I correct to assume this?

I actually rebuilt this package over at https://github.com/HarvestProfit/react-native-rectangle-scanner which you could try out. If the problem persists, then maybe I'm incorrect to assume that, but my package handles all capturing via manually (it uses javascript to auto call the manual capture function). I've had zero issues with this method.

@antoinerousseau
Copy link

I'm having the same issue. It would be great to make it work on the simulator too, even if the image is black, to be able to test an app easily :)

Does react-native-rectangle-scanner work on the iOS simulator?

@humphreyja
Copy link

@antoinerousseau It does work on an iOS simulator. It just shows a black screen. Also the onDeviceSetup function will send a hasCamera attribute that will be false so you can also show a custom message like "This device doesn't have a camera" if you want. I included that in the example.

Not working on a simulator was one of my biggest issues with this package and its derivatives which is why I included that requirement when I built the react-native-rectangle-scanner package.

@Speedy37
Copy link

Speedy37 commented Mar 2, 2020

See #38 for a fix, this is caused by dispatch_get_main_queue that was here before the set of fixes #26 It removed the non idiomatic singleton approach ( race condition and memory leaks )

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

5 participants