apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Apptentive registration on Worker thread #146

Closed bGorle closed 6 years ago

bGorle commented 6 years ago

I would like to do appetitive registration on worker thread, as it is giving ANR during register. While doing Apptentive.register, It is creating object for ApptentiveActivityLifeCycle where it is having the handler as member to that class. It is giving RuntimeException we can not create Handler on worker thread.

skykelsey commented 6 years ago

Hello @bGorle

Would you mind telling us the version of the Apptentive SDK you are using, and include the exception you are seeing?

bGorle commented 6 years ago

Sorry I didn't see the mail We are using the latest SDK version i.e 5.0.1

skykelsey commented 6 years ago

Thanks @bGorle

Can you please include the exception you are seeing?

bGorle commented 6 years ago

We got the stack trace for the ANR where it is failing. Actually there we are initializing the apptentive

Apptentive.register(Application.this, appTentiveKey,
                            appTentiveSignature);
weeeBox commented 6 years ago

All SDK related operations are performed on a background thread starting SDK v5.0.0

wshelor commented 5 years ago

This doesn't seem to be the case, @weeeBox - the SDK as of version 5.3.3 still crashes if you register on a background thread without preparing a looper for the handler. It sounds like this is not the intended behavior, right?

wshelor commented 5 years ago

Also note that in our testing apptentive takes 150-250ms to start. Seems a bit low for an ANR, but definitely way too much to add to application initialization. You guys should really dig into kicking off a background thread for all your initialization, as it takes a super long time (one of our top 3 third party initializations).

weeeBox commented 5 years ago

Thanks @wshelor, we'll prioritize this item and incorporate it in the future release.

dbharani commented 5 years ago

@weeeBox is this issue fixed on current release? I see similar ANRs with 5.3.3

dbharani commented 5 years ago

One of the device that we see this ANR consistently is:

Samsung Galaxy J7 Prime (j7popeltetmo), Android 8.1

ANR log

pc 000000000078d29d  /system/framework/arm/boot-framework.oat (Java_android_os_BinderProxy_transactNative__ILandroid_os_Parcel_2Landroid_os_Parcel_2I+132)
  at android.os.BinderProxy.transactNative (Native method)
  at android.os.BinderProxy.transact (Binder.java:777)
  at android.security.IKeystoreService$Stub$Proxy.exist (IKeystoreService.java:846)
  at android.security.KeyStore.contains (KeyStore.java:527)
  at android.security.keystore.AndroidKeyStoreSpi.engineContainsAlias (AndroidKeyStoreSpi.java:951)
  at java.security.KeyStoreSpi.engineGetEntry (KeyStoreSpi.java:493)
  at java.security.KeyStore.getEntry (KeyStore.java:1621)
  at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.loadExistingKey (KeyResolver23.java:59)
  at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.resolveSecretKey (KeyResolver23.java:44)
  at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.resolveKey (KeyResolver23.java:39)
  at com.apptentive.android.sdk.encryption.SecurityManager.resolveMasterKey (SecurityManager.java:79)
  at com.apptentive.android.sdk.encryption.SecurityManager.init (SecurityManager.java:45)
  at com.apptentive.android.sdk.ApptentiveInternal.<init> (ApptentiveInternal.java:169)
  at com.apptentive.android.sdk.ApptentiveInternal.createInstance (ApptentiveInternal.java:238)
- locked <0x022fbece> (a java.lang.Class<com.apptentive.android.sdk.ApptentiveInternal>)
  at com.apptentive.android.sdk.Apptentive.register (Apptentive.java:129)
  at com.apptentive.android.sdk.Apptentive.register (Apptentive.java:111)
dbharani commented 5 years ago

@skykelsey @weeeBox Should I create a new issue or will you guys re-open this? Let me know if developers need any further info, I live in Seattle

weeeBox commented 5 years ago

Hey @dbharani,

Please, update to 5.4.1. We made changes to the encryption handling.

dbharani commented 5 years ago

@weeeBox I am afraid it's not fixed with 5.4.1. I still see that ANR with Samsung Galaxy J7 Prime

at android.os.BinderProxy.transactNative (Native method) at android.os.BinderProxy.transact (Binder.java:777) at android.security.IKeystoreService$Stub$Proxy.exist (IKeystoreService.java:846) at android.security.KeyStore.contains (KeyStore.java:527) at android.security.keystore.AndroidKeyStoreSpi.engineContainsAlias (AndroidKeyStoreSpi.java:951) at java.security.KeyStoreSpi.engineGetEntry (KeyStoreSpi.java:493) at java.security.KeyStore.getEntry (KeyStore.java:1621) at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.loadExistingKey (KeyResolver23.java:59) at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.resolveSecretKey (KeyResolver23.java:44) at com.apptentive.android.sdk.encryption.resolvers.KeyResolver23.resolveKey (KeyResolver23.java:39) at com.apptentive.android.sdk.encryption.SecurityManager.resolveMasterKey (SecurityManager.java:106) at com.apptentive.android.sdk.encryption.SecurityManager.getEncryption (SecurityManager.java:61) at com.apptentive.android.sdk.ApptentiveInternal.<init> (ApptentiveInternal.java:170) at com.apptentive.android.sdk.ApptentiveInternal.createInstance (ApptentiveInternal.java:237) locked <0x0ac7d295> (a java.lang.Class<com.apptentive.android.sdk.ApptentiveInternal>) at com.apptentive.android.sdk.Apptentive.register (Apptentive.java:129) at com.apptentive.android.sdk.Apptentive.register (Apptentive.java:111)

weeeBox commented 5 years ago

@dbharani, would you open a separate issue for easier tracking?