iink SDK on Device

android sdk 识别so概率报错

你好,android sdk 识别概率报错,集成的版本是:api "com.myscript:iink:1.4.1",报错堆栈信息如下:

09-01 11:24:06.923 17719 30236 F libc : Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xc520a000 in tid 30236 (pool-7-thread-3), pid 17719 (gene.ssestudent)

09-01 11:24:06.993 30453 30453 D AndroidRuntime: Shutting down VM

09-01 11:24:07.062 30482 30482 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone

09-01 11:24:07.062 1009 1009 I /system/bin/tombstoned: received crash request for pid 30236

09-01 11:24:07.063 30482 30482 I crash_dump32: performing dump of process 17719 (target tid = 30236)

09-01 11:24:07.077 30482 30482 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

09-01 11:24:07.077 30482 30482 F DEBUG : Build fingerprint: 'ONYX/ZYJ101IOE3/ZYJ101IOE3:10/2021-07-23_12-30_3.0_3f969cc48/2393:user/dev-keys'

09-01 11:24:07.077 30482 30482 F DEBUG : Revision: '0'

09-01 11:24:07.077 30482 30482 F DEBUG : ABI: 'arm'

09-01 11:24:07.078 30482 30482 F DEBUG : Timestamp: 2021-09-01 11:24:07+0800

09-01 11:24:07.078 30482 30482 F DEBUG : pid: 17719, tid: 30236, name: pool-7-thread-3 >>> com.strongene.ssestudent <<<

09-01 11:24:07.078 30482 30482 F DEBUG : uid: 10065

09-01 11:24:07.078 30482 30482 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xc520a000

09-01 11:24:07.078 30482 30482 F DEBUG : r0 00000006 r1 a540bc60 r2 c520a000 r3 00000005

09-01 11:24:07.078 30482 30482 F DEBUG : r4 0135af00 r5 b4e027cc r6 ffffffff r7 f17065e5

09-01 11:24:07.078 30482 30482 F DEBUG : r8 0135af00 r9 c42bf050 r10 d81da800 r11 b4e02720

09-01 11:24:07.078 30482 30482 F DEBUG : ip 3e2aebc8 sp b4e026a8 lr 2525832b pc b8787490

09-01 11:24:07.080 30482 30482 F DEBUG :

09-01 11:24:07.080 30482 30482 F DEBUG : backtrace:

09-01 11:24:07.080 30482 30482 F DEBUG : #00 pc 00078490 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.080 30482 30482 F DEBUG : #01 pc 00072c3c /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.080 30482 30482 F DEBUG : #02 pc 00071658 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.080 30482 30482 F DEBUG : #03 pc 00071390 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.080 30482 30482 F DEBUG : #04 pc 00263d1c /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptText.so (BuildId: 2d1cdff717f0f695904e3626c46a989ae8c027c2)

09-01 11:24:07.080 30482 30482 F DEBUG : #05 pc 00200fbc /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptText.so (BuildId: 2d1cdff717f0f695904e3626c46a989ae8c027c2)

09-01 11:24:07.080 30482 30482 F DEBUG : #06 pc 00201bc8 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptText.so (BuildId: 2d1cdff717f0f695904e3626c46a989ae8c027c2)

09-01 11:24:07.080 30482 30482 F DEBUG : #07 pc 00044b78 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.080 30482 30482 F DEBUG : #08 pc 000be758 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #09 pc 000b9964 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #10 pc 0014240c /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #11 pc 00145dc8 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #12 pc 00145f8c /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #13 pc 000d5810 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptDocument.so (BuildId: 0d1bb10f9337ec50ed3fed42a6558aa5e77f680f)

09-01 11:24:07.081 30482 30482 F DEBUG : #14 pc 000d3d8c /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptDocument.so (BuildId: 0d1bb10f9337ec50ed3fed42a6558aa5e77f680f)

09-01 11:24:07.081 30482 30482 F DEBUG : #15 pc 00055b98 /data/app/com.strongene.ssestudent-Bm4GBSQN4BRjPTig7Fsvyw==/lib/arm/libMyScriptEngine.so (BuildId: 95d6746a4f29da456b092c22d67d86d78e7bcb23)

09-01 11:24:07.081 30482 30482 F DEBUG : #16 pc 000aa8ab /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: f964f9bad3f84fdf25f81d03b63edbb4)

09-01 11:24:07.081 30482 30482 F DEBUG : #17 pc 000619b3 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: f964f9bad3f84fdf25f81d03b63edbb4)



Dear Denny,


the below log doesn't help much.


Do you have a scenario that allows to reroduce, or a ideally a project?


Best regards,


Olivier

你好,我这边开启了10个线程,并发请求1000次,反复操作几次后就很大概率报这个错误;

每次都是新创建的editer,识别完就可以colse释放内存,现在是在我们的项目中出现这个情况

你好,我发现是多线程引起的,改成1或者2个线程没有问题,请问Editor 支持并发吗?如果支持并发,最大的数量是多少?


            DisplayMetrics displayMetrics = CoreApplication.CONTEXT.getResources().getDisplayMetrics();

            Renderer renderer = mEngine.createRenderer(displayMetrics.xdpi, displayMetrics.ydpi, null);

 

            // Create the editor

            Editor editor = mEngine.createEditor(renderer);

 

            editor.addListener(listener);

 

            // The editor requires a font metrics provider and a view size *before* calling setPart()

            Map<String, Typeface> typefaceMap = new HashMap<>();

            editor.setFontMetricsProvider(new FontMetricsProvider(displayMetrics, typefaceMap)); // can't be null

            editor.setViewSize(displayMetrics.widthPixels, displayMetrics.heightPixels);

            editor.setPart(mPackage.createPart(type));

Dear Denny,


thank you for the explanation.


Currently, we are trying to figure out your use-case:

-If I understand well, you create 10 instances of the iink SDK in parallel

-When you say you process 1000 ink, how do you proceed? Do you sent 100 inks sequentially on each thread? If so, what is the size of these inks?

-Is it in "interactive mode"?

-Or in offscreen non interactive mode (i.e. ink is provided as a series of events) ? : https://developer.myscript.com/docs/interactive-ink/1.4/android/fundamentals/editing/#series-of-events


Please explain.


Also, what is the hardware configuration of your device? How many core does your CPU have? What is the RAM size?....


What is the purpose of creating so many threads? Indeed, our usual recommendation is that to have at maximum one thread per core... and ensure you have enough memory.


And your use-case is something that has not been tried on Android, we cannot therefore guarantee it will work properly.


So, at present, based on your below explnations, our recommendations is that you create less threads, monitor the RAM, and check it works fine.


Also, please answer the above questions, so that we can have a better overview of your use-case, and may think of another way to proceed.


Indeed, we are insisting the handwriting recognition is a demanding process, and your use-case would be more appropriate on a server usage.


Best regards,


Olivier

你好,我识别的时候,通过androidStudio的profilter工具检测内存变化,内存监控是平稳上升的,在400MB到600MB左右,java多线程是任务执行完就自动执行队列的下一个任务,没有说每个线程就是执行100个任务;

主要是在每个线程内部创建一个editor,识别完调用String result = editor.export_(editor.getRootBlock(), mimeType);等到每个数据的识别结果,最后调用如下clearEditor关闭和释放内存

private void clearEditor(Editor editor) {

        if (ObjectUtils.isEmpty(editor)) {

            return;

        }

        ContentPart contentPart = editor.getPart();

        if (ObjectUtils.isNotEmpty(contentPart)) {

            editor.getPart().close();

            editor.setPart(null);

        }

        editor.close();

 

    }



我在android10.0的机器上验证的,app的内存可以到达1GB,app申请了大内存,cpu是8核心,高通骁龙636;我们是在后台执行的任务,是用户把作业的所有填空题全部做完,提交的时候,一起批量识别,是在一个后台任务执行的,所以需要多线程来提供识别的时间;你们可以先验证,需要更多信息可以给我回复,我再提供,谢谢。

Dear Denny,


currently, we do not see anything wrong in your above code.


On your side, did you try with less threads (e.g. 4)? Did you try on a recent Android device? Is it still crashing?


Also, we are trying to figure out your use-case. Indeed, such scenario, having 10 threads in parallel would likely be more a server use-case, which would run on Linux or Windows. Can you please explain the purpose?


Also, as this crash is not known on our side, if you want us to investigate further, please provide with a full project (and your ink samples) that allows to reproduce. Otherwise, we will not be able to work on this.


Thank you,


Best regards,


Olivier

Login or Signup to post a comment