blinkid-android icon indicating copy to clipboard operation
blinkid-android copied to clipboard

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

Open giacomuzzi opened this issue 2 years ago • 7 comments

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?

giacomuzzi avatar Aug 07 '23 16:08 giacomuzzi