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

meizu devices tif save problem #11

Closed
noamamiran opened this Issue Dec 12, 2016 · 11 comments

Comments

Projects
None yet
2 participants
@noamamiran

noamamiran commented Dec 12, 2016

on every meizu device i got the error : org.beyka.tiffbitmapfactory.exceptions.NoSuchFileException
The native method TIFFOpen(strPath, "w") always returns null.
do you know this kind of issue?

@Beyka

This comment has been minimized.

Show comment
Hide comment
@Beyka

Beyka Dec 12, 2016

Owner

Hello. Did you use build from gradle repository or you built it by yourself?
Also did you used android.permission.WRITE_EXTERNAL_STORAGE permission? If your device has android 6.0 than you should use runtime permissions.
If TIFFOpen(strPath, "w") returns null it's mean that file not exist or file can't be opened for writing.
And could you attach full log of error from logcat and what devices and android versions you are using?
Thank you.

Owner

Beyka commented Dec 12, 2016

Hello. Did you use build from gradle repository or you built it by yourself?
Also did you used android.permission.WRITE_EXTERNAL_STORAGE permission? If your device has android 6.0 than you should use runtime permissions.
If TIFFOpen(strPath, "w") returns null it's mean that file not exist or file can't be opened for writing.
And could you attach full log of error from logcat and what devices and android versions you are using?
Thank you.

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 12, 2016

Hi,
I built in myself not using the gradle, the error raised only on meizu manufacturer models.
It's not runtime permission because I handled it and it also occurred on Android 5.
I will attach the log ASAP.
Thank you!

noamamiran commented Dec 12, 2016

Hi,
I built in myself not using the gradle, the error raised only on meizu manufacturer models.
It's not runtime permission because I handled it and it also occurred on Android 5.
I will attach the log ASAP.
Thank you!

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 15, 2016

hello beyka,
this is the logcat output, i think the problem somehow connected to the first two lines:

12-16 00:07:30.100 16213-16262/my.package.name W/linker: libtiffsaver.so: unused DT entry: type 0x6ffffffe arg 0xfd4
12-16 00:07:30.100 16213-16262/my.package.name W/linker: libtiffsaver.so: unused DT entry: type 0x6fffffff arg 0x1
12-16 00:07:30.121 16213-16262/my.package.name E/NativeTiffSaver: Unable to write tif file
12-16 00:07:30.133 16213-16269/my.package.name W/GooglePlayServicesUtil: Google Play services out of date. Requires 9683000 but found 9256248
12-16 00:07:30.305 16213-16302/my.package.name I/System.out: [OkHttp] sendRequest<<
12-16 00:07:30.330 16213-16262/my.package.name E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: my.package.name, PID: 16213
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.beyka.tiffbitmapfactory.exceptions.NoSuchFileException: No such file /data/data/my.package.name/images/ocr_rec_pic_20160716120730-1347768532.tif
at org.beyka.tiffbitmapfactory.TiffSaver.saveMultipleMonochrome(Native Method)
at org.beyka.tiffbitmapfactory.TiffSaver.saveBitmapsMonochrome(TiffSaver.java:140)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.saveTif(ReceiptPreConfirmationActivity.java:411)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.createUploadFiles(ReceiptPreConfirmationActivity.java:344)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.access$400(ReceiptPreConfirmationActivity.java:59)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity$FilesCreationAsyncTask.doInBackground(ReceiptPreConfirmationActivity.java:237)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity$FilesCreationAsyncTask.doInBackground(ReceiptPreConfirmationActivity.java:227)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) 

noamamiran commented Dec 15, 2016

hello beyka,
this is the logcat output, i think the problem somehow connected to the first two lines:

12-16 00:07:30.100 16213-16262/my.package.name W/linker: libtiffsaver.so: unused DT entry: type 0x6ffffffe arg 0xfd4
12-16 00:07:30.100 16213-16262/my.package.name W/linker: libtiffsaver.so: unused DT entry: type 0x6fffffff arg 0x1
12-16 00:07:30.121 16213-16262/my.package.name E/NativeTiffSaver: Unable to write tif file
12-16 00:07:30.133 16213-16269/my.package.name W/GooglePlayServicesUtil: Google Play services out of date. Requires 9683000 but found 9256248
12-16 00:07:30.305 16213-16302/my.package.name I/System.out: [OkHttp] sendRequest<<
12-16 00:07:30.330 16213-16262/my.package.name E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: my.package.name, PID: 16213
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.beyka.tiffbitmapfactory.exceptions.NoSuchFileException: No such file /data/data/my.package.name/images/ocr_rec_pic_20160716120730-1347768532.tif
at org.beyka.tiffbitmapfactory.TiffSaver.saveMultipleMonochrome(Native Method)
at org.beyka.tiffbitmapfactory.TiffSaver.saveBitmapsMonochrome(TiffSaver.java:140)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.saveTif(ReceiptPreConfirmationActivity.java:411)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.createUploadFiles(ReceiptPreConfirmationActivity.java:344)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity.access$400(ReceiptPreConfirmationActivity.java:59)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity$FilesCreationAsyncTask.doInBackground(ReceiptPreConfirmationActivity.java:237)
at my.package.name.activities.receipt.ReceiptPreConfirmationActivity$FilesCreationAsyncTask.doInBackground(ReceiptPreConfirmationActivity.java:227)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) 

@Beyka

This comment has been minimized.

Show comment
Hide comment
@Beyka

Beyka Dec 16, 2016

Owner

Did you build library from master branch? and what is ABI of phones that not working? armv7a or maybe some x64?
Also which version of android NDK was used?

Also I made some investigation and I can't get path like yours " /data/data/my.package.name/images/ocr_rec_pic_20160716120730-1347768532.tif". Do you trying to get this file path by using some special function of Context of you just trying new File("yours_full_path").
If you trying to create this path manualy - it will not work. Try to use Context.getFilesDir()

One case when I got NoSuchFileException it when I used this code:
File saveFile = new File("/data/data/com.beyka.tiffsample/images/saved_none.tif");
In all other cases saving is working.

Thank you.

Owner

Beyka commented Dec 16, 2016

Did you build library from master branch? and what is ABI of phones that not working? armv7a or maybe some x64?
Also which version of android NDK was used?

Also I made some investigation and I can't get path like yours " /data/data/my.package.name/images/ocr_rec_pic_20160716120730-1347768532.tif". Do you trying to get this file path by using some special function of Context of you just trying new File("yours_full_path").
If you trying to create this path manualy - it will not work. Try to use Context.getFilesDir()

One case when I got NoSuchFileException it when I used this code:
File saveFile = new File("/data/data/com.beyka.tiffsample/images/saved_none.tif");
In all other cases saving is working.

Thank you.

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 18, 2016

yes, the library is from the master branch.
the ABI is armx64
NDK Build 13
i changed the save method to use Context.getFilesDir() and create sub folder beneath it, called images
and yet, it refused to work :(
Caused by: org.beyka.tiffbitmapfactory.exceptions.NoSuchFileException: No such file /data/data/my.package.name/files/images/ocr_rec_pic_201603180403491784540144.tif

i will try deeper to look into the problem

noamamiran commented Dec 18, 2016

yes, the library is from the master branch.
the ABI is armx64
NDK Build 13
i changed the save method to use Context.getFilesDir() and create sub folder beneath it, called images
and yet, it refused to work :(
Caused by: org.beyka.tiffbitmapfactory.exceptions.NoSuchFileException: No such file /data/data/my.package.name/files/images/ocr_rec_pic_201603180403491784540144.tif

i will try deeper to look into the problem

@Beyka

This comment has been minimized.

Show comment
Hide comment
@Beyka

Beyka Dec 18, 2016

Owner

@noamamiran

the ABI is armx64
Master bransh hasn't support for any x64 system for now. Please try x64_support branch or wait few days while I finish merging
NDK Build 13
I used NDK Build 10. Need to check 13 version. Maybe some problem with linking

Also it's strange that on armx64 you didn't got UnsatisfiedLinkError.
Any way did you tried to save your images to external memmory using Environment.getExternalStorageDirectory() as root? Maybe your meizu device not allow to write files into the inner memmory or you just hasn't free space?

Owner

Beyka commented Dec 18, 2016

@noamamiran

the ABI is armx64
Master bransh hasn't support for any x64 system for now. Please try x64_support branch or wait few days while I finish merging
NDK Build 13
I used NDK Build 10. Need to check 13 version. Maybe some problem with linking

Also it's strange that on armx64 you didn't got UnsatisfiedLinkError.
Any way did you tried to save your images to external memmory using Environment.getExternalStorageDirectory() as root? Maybe your meizu device not allow to write files into the inner memmory or you just hasn't free space?

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 18, 2016

i didnt get UnsatisfiedLinkError becuase in the gradle file i define abiFilters
ndk {
abiFilters 'x86', 'mips', 'armeabi', 'armeabi-v7a'
}

getExternalStorageDirectory - also didn't work

i looked into the tif_unix.c file and exract some native code directly to the NativeTiffSaver.cpp file and successfully managed to get it work in this way:

int mode = O_RDWR | O_CREAT | O_TRUNC | 0;
int fd = open(strPath, mode, 0666);
if (fd<0){
throw_no_such_file_exception(env, filePath);
return JNI_FALSE;
}

if ((tiff = TIFFFdOpen(fd, strPath, "w")) == NULL) {
close(fd);
LOGE("Unable to write tif file");
throw_no_such_file_exception(env, filePath);
return JNI_FALSE;
}
don't ask me why, but this is working, maybe the ifdef condition cause problems, i will try to find why.
anyway this patch will be target only for meizu devices.

noamamiran commented Dec 18, 2016

i didnt get UnsatisfiedLinkError becuase in the gradle file i define abiFilters
ndk {
abiFilters 'x86', 'mips', 'armeabi', 'armeabi-v7a'
}

getExternalStorageDirectory - also didn't work

i looked into the tif_unix.c file and exract some native code directly to the NativeTiffSaver.cpp file and successfully managed to get it work in this way:

int mode = O_RDWR | O_CREAT | O_TRUNC | 0;
int fd = open(strPath, mode, 0666);
if (fd<0){
throw_no_such_file_exception(env, filePath);
return JNI_FALSE;
}

if ((tiff = TIFFFdOpen(fd, strPath, "w")) == NULL) {
close(fd);
LOGE("Unable to write tif file");
throw_no_such_file_exception(env, filePath);
return JNI_FALSE;
}
don't ask me why, but this is working, maybe the ifdef condition cause problems, i will try to find why.
anyway this patch will be target only for meizu devices.

@Beyka

This comment has been minimized.

Show comment
Hide comment
@Beyka

Beyka Dec 19, 2016

Owner

TIFFFdOpen is like TIFFOpen except that it opens a TIFF file given an open file descriptor fd. The file's name and mode must reflect that of the open descriptor. The object associated with the file descriptor must support random access.
So you just get filedescriptor and than open tiff with it. It's strange that this function is working. I think that I will add this code for cases when TiffOpen not work. Thanks for solution :)

Owner

Beyka commented Dec 19, 2016

TIFFFdOpen is like TIFFOpen except that it opens a TIFF file given an open file descriptor fd. The file's name and mode must reflect that of the open descriptor. The object associated with the file descriptor must support random access.
So you just get filedescriptor and than open tiff with it. It's strange that this function is working. I think that I will add this code for cases when TiffOpen not work. Thanks for solution :)

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 19, 2016

I agree, this is so strange indeed.

noamamiran commented Dec 19, 2016

I agree, this is so strange indeed.

@Beyka

This comment has been minimized.

Show comment
Hide comment
@Beyka

Beyka Dec 19, 2016

Owner

Any way thank you for big work which you did. Your solution will be added soon to repo.

Owner

Beyka commented Dec 19, 2016

Any way thank you for big work which you did. Your solution will be added soon to repo.

@noamamiran

This comment has been minimized.

Show comment
Hide comment
@noamamiran

noamamiran Dec 19, 2016

Thank you for the big work, it's not trivial task

noamamiran commented Dec 19, 2016

Thank you for the big work, it's not trivial task

@Beyka Beyka closed this Dec 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment