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

The native library is loaded in the main thread, which generates an ANR #299

Open
giacomuzzi opened this issue Aug 7, 2023 · 7 comments

Comments

@giacomuzzi
Copy link

Description

We are experiencing ANR events when the license is set in the Application.onCreate callback. The ANR is triggered because the libBlinkID.so library is being loaded in the main thread. Please refer to the following stack trace for more details

main (native):tid=1 systid=13419 
#00 pc 0xd7758 libc.so (sched_setaffinity + 8)
#01 pc 0x3b6290 split_config.arm64_v8a.apk!libBlinkID.so + 4096
       at java.lang.Runtime.nativeLoad(Native method)
       at java.lang.Runtime.nativeLoad(Runtime.java:1131)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1085)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
       at java.lang.System.loadLibrary(System.java:1664)
       at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:9)
       at com.microblink.blinkid.hardware.MicroblinkDeviceManager.<clinit>(line:35)
       at com.microblink.blinkid.hardware.MicroblinkDeviceManager.IllIIIIllI(MicroblinkDeviceManager.java:1)
       at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:3)
       at com.microblink.blinkid.secured.lIlIllllII.llIIlIlIIl(line:1)
       at com.microblink.blinkid.MicroblinkSDK.<clinit>(line:1)
       at com.example.MyApp.onCreate(MyApp.kt:80)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7593)
       at android.app.ActivityThread.access$1500(ActivityThread.java:301)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2177)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8653)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Environment Details

BlinkID version:
6.1.2

Device model:
multiple devices (Samsung Galaxy A51, Samsung Galaxy A50, Samsung Galaxy M31)

Device Android version:
Android 11, 12 and 13

Device ABI (processor architecture, e.g. ARMv7):
arm64-v8a

Additional information

In addition to the bug, I would like to comment that we'd prefer not to initialize Microblink in the Application.onCreate callback. This is because Microblink is not used every time the app is opened; on the contrary, most of the time it is not used. Instead, we'd like to initialize Microblink only when we need it. Could you provide a way to initialize the library only when needed?

@somyaguptagit
Copy link

Hello! Thank you for reaching out! Would you mind sharing how you are setting up the license? Would you also share the license number(starting LIC00..) that you are using?
Does the issue only appear on Samsung devices? Have you tried testing it on other Android devices?

@giacomuzzi
Copy link
Author

giacomuzzi commented Aug 8, 2023

Hello! Thank you for your response!

Would you mind sharing how you are setting up the license?

We are setting up the license as follows:

    override fun onCreate() {
        super.onCreate()
        // ... other initializations 
        MicroblinkSDK.setLicenseFile("licenses/microblink/license.key", this)
    }

Does the issue only appear on Samsung devices?

The issue appears mostly on Samsung devices. Take a look at this screenshot from Crashlytics for the last 30 days
image

Have you tried testing it on other Android devices?

I'm testing on a Moto G (5) Plus but I can't reproduce the error. However, if I enable StrictMode I get several strict policy violations:

StrictMode policy violation; ~duration=111 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65543 violation=2
 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1449)
 at java.io.UnixFileSystem.list(UnixFileSystem.java:302)
 at java.io.File.list(File.java:1122)
 at java.io.File.listFiles(File.java:1286)
 at com.microblink.blinkid.secured.IIIlllIlII.<clinit>(line:3)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.<clinit>(line:1)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.IllIIIIllI(line:1)
 at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:3)
 at com.microblink.blinkid.secured.lIlIllllII.llIIlIlIIl(line:1)
 at com.microblink.blinkid.MicroblinkSDK.<clinit>(line:1)
 at com.microblink.blinkid.MicroblinkSDK.setLicenseFile(Unknown Source:0)
 at com.example.MyApp.onCreate(MyApp.kt:126)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1141)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5854)
 at android.app.ActivityThread.-wrap1(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1697)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loop(Looper.java:164)
 at android.app.ActivityThread.main(ActivityThread.java:6626)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

StrictMode policy violation; ~duration=103 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65543 violation=2
 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1449)
 at libcore.io.BlockGuardOs.open(BlockGuardOs.java:203)
 at libcore.io.IoBridge.open(IoBridge.java:498)
 at java.io.RandomAccessFile.<init>(RandomAccessFile.java:274)
 at java.io.RandomAccessFile.<init>(RandomAccessFile.java:141)
 at com.microblink.blinkid.secured.IIIlllIlII.llIIlIlIIl(line:21)
 at com.microblink.blinkid.secured.IIIlllIlII.<clinit>(line:16)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.<clinit>(line:1)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.IllIIIIllI(line:1)
 at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:3)
 at com.microblink.blinkid.secured.lIlIllllII.llIIlIlIIl(line:1)
 at com.microblink.blinkid.MicroblinkSDK.<clinit>(line:1)
 at com.microblink.blinkid.MicroblinkSDK.setLicenseFile(Unknown Source:0)
 at com.example.MyApp.onCreate(MyApp.kt:126)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1141)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5854)
 at android.app.ActivityThread.-wrap1(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1697)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loop(Looper.java:164)
 at android.app.ActivityThread.main(ActivityThread.java:6626)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

StrictMode policy violation; ~duration=101 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65543 violation=2
 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1449)
 at libcore.io.BlockGuardOs.fstat(BlockGuardOs.java:153)
 at libcore.io.IoBridge.open(IoBridge.java:501)
 at java.io.RandomAccessFile.<init>(RandomAccessFile.java:274)
 at java.io.RandomAccessFile.<init>(RandomAccessFile.java:141)
 at com.microblink.blinkid.secured.IIIlllIlII.llIIlIlIIl(line:21)
 at com.microblink.blinkid.secured.IIIlllIlII.<clinit>(line:16)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.<clinit>(line:1)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.IllIIIIllI(line:1)
 at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:3)
 at com.microblink.blinkid.secured.lIlIllllII.llIIlIlIIl(line:1)
 at com.microblink.blinkid.MicroblinkSDK.<clinit>(line:1)
 at com.microblink.blinkid.MicroblinkSDK.setLicenseFile(Unknown Source:0)
 at com.example.MyApp.onCreate(MyApp.kt:126)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1141)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5854)
 at android.app.ActivityThread.-wrap1(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1697)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loop(Looper.java:164)
 at android.app.ActivityThread.main(ActivityThread.java:6626)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

StrictMode policy violation; ~duration=99 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65543 violation=2
 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1449)
 at libcore.io.BlockGuardOs.read(BlockGuardOs.java:250)
 at libcore.io.IoBridge.read(IoBridge.java:528)
 at java.io.RandomAccessFile.readBytes(RandomAccessFile.java:359)
 at java.io.RandomAccessFile.read(RandomAccessFile.java:388)
 at java.io.RandomAccessFile.read(RandomAccessFile.java:346)
 at java.io.RandomAccessFile.readLine(RandomAccessFile.java:976)
 at com.microblink.blinkid.secured.IIIlllIlII.llIIlIlIIl(line:23)
 at com.microblink.blinkid.secured.IIIlllIlII.<clinit>(line:16)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.<clinit>(line:1)
 at com.microblink.blinkid.hardware.MicroblinkDeviceManager.IllIIIIllI(line:1)
 at com.microblink.blinkid.secured.lIlIllllII.IllIIIllII(line:3)
 at com.microblink.blinkid.secured.lIlIllllII.llIIlIlIIl(line:1)
 at com.microblink.blinkid.MicroblinkSDK.<clinit>(line:1)
 at com.microblink.blinkid.MicroblinkSDK.setLicenseFile(Unknown Source:0)
 at com.example.MyApp.onCreate(MyApp.kt:126)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1141)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5854)
 at android.app.ActivityThread.-wrap1(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1697)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loop(Looper.java:164)
 at android.app.ActivityThread.main(ActivityThread.java:6626)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

Would you also share the license number(starting LIC00..) that you are using?

LIC03000054510

@somyaguptagit
Copy link

Thank you for sharing the requested information. This is a known issue on Samsung devices and we have forwarded it to our internal teams, as soon as we have an update, we will make a follow-up here.

@somyaguptagit
Copy link

Hello @giacomuzzi, Our internal teams have requested the below details in order to reproduce the crash.
Do you maybe have a minimal reproducible sample app? If yes, please share it with us.
Also, can you please share the full crash logs? How often does the crash happen?
Once you share the requested information, we will forward these details internally and reach out with an update. Thank you.

@giacomuzzi
Copy link
Author

Hello @somyaguptagit , you can enable StrictMode to detect which operations shouldn't be executed on the main thread, if you keep those operations off the main thread you will fix the bug.

@aottonello
Copy link

Hi @somyaguptagit I have the same issue with ANR events. When initializing the Microblink SDK in the application's onCreate method. The libBlinkID.so library is being loaded in the main thread and generate ANR.
Can you give the most up-to-date information and guidance on how to solve this problem ?

@somyaguptagit
Copy link

Hello @aottonello Would you kindly reach out to Microblink Support([email protected]) with the below-requested information so we can continue troubleshooting over there?
Also, it would be helpful if you can share a minimal reproducible sample app. Thank you.

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