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

Crashes when loaded from another app #33

Closed
rugk opened this issue May 2, 2016 · 15 comments
Closed

Crashes when loaded from another app #33

rugk opened this issue May 2, 2016 · 15 comments

Comments

@rugk
Copy link

rugk commented May 2, 2016

I have another all which allows you to chose "camera" for sharing photos. There you chose the camera so and the camera so sends the picture back to the app for further processing.
However when I choose your app there it always crashes after I take a photo.

Logcat:

I/PackageManager(  618): Setting last chosen activity com.todobom.opennotescanner/.OpenNoteScannerActivity for user 0:
I/ActivityManager(  618): START u0 {act=android.media.action.IMAGE_CAPTURE flg=0x3000003 cmp=com.todobom.opennotescanner/.OpenNoteScannerActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/ch.*******.app/files/tmp/.camera--555360234.jpg.nomedia} (has extras)} from uid 10202 on display 0
I/ActivityManager(  618): Start proc 16955:com.todobom.opennotescanner/u0a107 for activity com.todobom.opennotescanner/.OpenNoteScannerActivity
W/System  (16955): ClassLoader referenced unknown path: /data/app/com.todobom.opennotescanner-2/lib/arm
W/XPrivacy(16955): Hooking package=com.todobom.opennotescanner
D/OpenNoteScannerActivity(16955): resuming
D/OpenNoteScannerActivity(16955): myBuild armeabi-v7a
D/OpenNoteScannerActivity(16955): myBuild armeabi
I/ActivityManager(  618): Displayed com.todobom.opennotescanner/.OpenNoteScannerActivity: +1s117ms
D/OpenNoteScannerActivity(16955): supported preview resolution: 1920x1080
D/OpenNoteScannerActivity(16955): supported picture resolution: 4128x3096 ratio: 1.3333334
D/OpenNoteScannerActivity(16955): supported picture resolution: 4128x2322 ratio: 1.7777778
D/OpenNoteScannerActivity(16955): supported picture resolution: 3264x2448 ratio: 1.3333334
D/OpenNoteScannerActivity(16955): supported picture resolution: 3264x1836 ratio: 1.7777778
D/OpenNoteScannerActivity(16955): supported picture resolution: 2048x1536 ratio: 1.3333334
D/OpenNoteScannerActivity(16955): supported picture resolution: 2048x1152 ratio: 1.7777778
D/OpenNoteScannerActivity(16955): supported picture resolution: 1280x720 ratio: 1.7777778
D/OpenNoteScannerActivity(16955): supported picture resolution: 640x480 ratio: 1.3333334
D/OpenNoteScannerActivity(16955): Max supported picture resolution with preview aspect ratio: 4128x2322
D/OpenNoteScannerActivity(16955): max supported picture resolution: 4128x2322
D/OpenNoteScannerActivity(16955): enabling autofocus
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@549fd91
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@549fd91
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@ae954f6
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@ae954f6
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@98050f7
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@98050f7
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@a57eb64
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@a57eb64
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@47fe1cd
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@47fe1cd
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@2cdca82
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@2cdca82
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@7df0593
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@7df0593
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@eee7a6
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@eee7a6
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@b165e7
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@b165e7
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@3ef594
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@3ef594
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@e19d83d
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@e19d83d
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@1519871
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@1519871
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: available
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@4968656
D/ImageProcessor(16955): Message Received: previewFrame - com.todobom.opennotescanner.helpers.PreviewFrame@4968656
D/OpenNoteScannerActivity(16955): onPreviewFrame - received image 1920x1080 focused: true imageprocessor: busy
D/OpenNoteScannerActivity(16955): onPictureTaken - received image 4128x2322
D/OpenNoteScannerActivity(16955): sending message to ImageProcessor: pictureTaken - Mat [ 2322*4128*CV_8UC1, isCont=true, isSubmat=false, nativeObj=0xffffffff9c159f50, dataAddr=0xffffffff970c0010 ]
E/AndroidRuntime(16955): Process: com.todobom.opennotescanner, PID: 16955
E/AndroidRuntime(16955):    at com.todobom.opennotescanner.OpenNoteScannerActivity.saveDocument(OpenNoteScannerActivity.java:889)
E/AndroidRuntime(16955):    at com.todobom.opennotescanner.ImageProcessor.processPicture(ImageProcessor.java:159)
E/AndroidRuntime(16955):    at com.todobom.opennotescanner.ImageProcessor.handleMessage(ImageProcessor.java:90)
W/ActivityManager(  618):   Force finishing activity com.todobom.opennotescanner/.OpenNoteScannerActivity
I/ActivityManager(  618): Process com.todobom.opennotescanner (pid 16955) has died
@allgood
Copy link
Owner

allgood commented May 2, 2016

Hi @rugk , I've tested with telegram and didn't happened any error, can you confirm you are working on last version?

What is the app you are using to call Open Note Scanner from?

Best regards,
Claudemir

@rugk rugk changed the title Crashes when leaded from another app Crashes when loaded from another app May 2, 2016
@rugk
Copy link
Author

rugk commented May 2, 2016

I also tested it with other apps now and I did only get this error with this particular app. I'll report it to them and see what they say.
Stay tuned!

I'm using the latest version available on FDroid.

@allgood
Copy link
Owner

allgood commented May 2, 2016

F-Droid didn't updated to 1.0.23 yet. If the app you are having problem with is available, I can try to reproduce the error here.

@rugk
Copy link
Author

rugk commented May 2, 2016

Okay, the app is Threema.

Here's how they call an external camera:

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraUri);
startActivityForResult(cameraIntent, ID_PICK_CAMERA);

@allgood
Copy link
Owner

allgood commented May 2, 2016

Well, it is a paid app, so I can not test. Looks there is nothing wrong with the calling code. But everything that involve paths have differences between android versions also.

If you are a developer, you can help me tracking this down debugging the app on OpenNoteScannerActivity.java line 899 ... it is the line that saves the file.

Anyway, I will try to implement some debug messages there for the next version at least, this will give me more debug information.

@allgood
Copy link
Owner

allgood commented May 2, 2016

Oops... line 889

@rugk
Copy link
Author

rugk commented May 2, 2016

You could have just linked to that line, but as I am no developer I'm sorry I can't help debugging it.
But I can submit another logcat when more debug messages are implemented.

@mimiks
Copy link

mimiks commented May 3, 2016

OpenNoteScanner (or rather OpenCV) attempts to select the appropriate image writer from looking at the extension of the suggested file name provided by the MediaStore.EXTRA_OUTPUT extra parameter. Apparently, Threema uses a file name that does not include a recognized extension.

Hence, OpenCV crashes with:
OpenCV Error: Unspecified error (could not find a writer for the specified extension)

@rugk
Copy link
Author

rugk commented May 3, 2016

So is this the fault of Threema or OpenNoteScanner?

@mimiks
Copy link

mimiks commented May 4, 2016

Evaluating file name extensions of the path component of an URI is not a good way to determine what format the output should be. Or, at least, a default format should be used, if the extension is not recognized.

If you want the calling app to be able to choose the format, using ContentValues with a Images.Media.MIME_TYPE parameter might be a better idea.

@allgood
Copy link
Owner

allgood commented May 4, 2016

@rugk, I do not know yet, it is possible that OpenNoteScanner doesn't handle the call from Threema correctly.

@mimiks, OpenNoteScanner for now saves only jpeg files, so, this can be the problem. Will look about the parameter you told for the next release.

Please remember folks that I do this on my spare time! :-D

@allgood
Copy link
Owner

allgood commented May 4, 2016

@mimiks, Now I read your previous message. I was thinking that OpenCV was using always jpg, but, this can be the case also.

I will spend some bucks on Threema in order to debug this correctly.

@rugk, please send me your Threema id on a private message. EDIT: not needed... just saw the ECHO TEST contact there. Problem was reproduced and confirmed, will debug it later.

@allgood allgood closed this as completed in 6add0a1 May 4, 2016
@allgood
Copy link
Owner

allgood commented May 4, 2016

@rugk - Lunch time quick fix... already uploaded to Google Play and releases section

@mimiks
Copy link

mimiks commented May 4, 2016

Thanks for the quick fix. Works well! I really appreciate your efforts.

There's one more thing to consider: Some apps may provide an URI that refers to a content provider rather than a file. In that case, the URI scheme starts with content:// rather than file:// and fileUri.getPath()(line 870) will not return a file path.

A comprehensive example of how to get the path from file-based content providers can be found here:
FileUtils.java

@allgood
Copy link
Owner

allgood commented May 4, 2016

@mimiks , will try to look at it, no promises for now since I want to make some enhancements on the gallery and image viewer. Created issue #37 to track this problem.

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

3 participants