BlinkID / blinkid-react-native

ID scanning for cross-platform apps built with ReactNative.
175 stars 59 forks source link

Fatal Exception: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. #177

Open ketnatnoon opened 3 years ago

ketnatnoon commented 3 years ago

I faced this issue in production app. The reason I believe BlinkID caused this crash is that firebase logged firebase_screen_class:BlinkIdActivity right before the crash. The following were the logs on Crashlytics:

Fatal Exception: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
       at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:10763)
       at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:2222)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.view.View.requestLayout(View.java:27055)
       at android.widget.TextView.onConfigurationChanged(TextView.java:4595)
       at android.view.View.dispatchConfigurationChanged(View.java:15824)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1662)
       at android.view.ViewRootImpl.updateConfiguration(ViewRootImpl.java:5840)
       at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6678)
       at android.app.servertransaction.ActivityConfigurationChangeItem.execute(ActivityConfigurationChangeItem.java:51)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8512)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Picasso-Stats
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:206)
       at android.os.HandlerThread.run(HandlerThread.java:67)

Recognition
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:206)
       at com.microblink.util.llIIlIIlll.run(llIIlIIlll.java:21)

Camera2Control 167302515
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:206)
       at com.microblink.util.llIIlIIlll.run(llIIlIIlll.java:21)

Device Information:

Brand: Samsung
Model: Galaxy A50
Platform: Android
Version: 11

Based on Stack Overflow, the issue can be resolved via https://stackoverflow.com/a/5162096/5115097 but not sure where the aforementioned issue is.

anjapenic commented 3 years ago

Hello,

This issue will be fixed in the next SDK release, for now, you can use this solution - in your application’s AndroidManifest.xml (should be on this path: <your_app_root_folder>/android/app/src/main/AndroidManifest.xml), inside <application> tag, add following lines:

<activity
    android:name="com.microblink.activity.BlinkIdActivity"
    android:noHistory="true"/>

Let us know if it helped!

Best regards, Anja