Marketo / android-sdk

The Marketo Mobile SDK allows integration with Marketo Mobile Engagement.
Other
7 stars 5 forks source link

ANR caused by Marketo SDK 0.8.0 #15

Closed ColtonIdle closed 5 years ago

ColtonIdle commented 5 years ago

I'm using the latest Marketo SDK 0.8.0 and I'm getting reports of ANRs in production. Please investigate and fix as soon as you can. Please and thank you!

Stacktrace:

ANR: Application did not respond for at least 5000 ms
        at com.marketo.Marketo.b(SourceFile:20822)
        at com.marketo.Marketo$a.onActivityStopped(SourceFile:947)
        at android.app.Application.dispatchActivityStopped(Application.java:282)
        at android.app.Activity.onStop(Activity.java:1984)
        at androidx.fragment.app.FragmentActivity.onStop(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStop(AppCompatActivity.java:185)

Threads:

SourceFile:20822com.marketo.Marketo.b   
SourceFile:947com.marketo.Marketo$a.onActivityStopped   
Application.java:282android.app.Application.dispatchActivityStopped 
Activity.java:1984android.app.Activity.onStop   
FragmentActivity.java:541androidx.fragment.app.FragmentActivity.onStop  
AppCompatActivity.java:185androidx.appcompat.app.AppCompatActivity.onStop   
Base.java:95com.mobilemarket.app.Base.onStop    
MyActivity.kt:214com.mobilemarket.onboarding.MyActivity.onStop  
Instrumentation.java:1432android.app.Instrumentation.callActivityOnStop 
Activity.java:7653android.app.Activity.performStop  
ActivityThread.java:4372android.app.ActivityThread.callActivityOnStop   
ActivityThread.java:4350android.app.ActivityThread.performStopActivityInner 
ActivityThread.java:4425android.app.ActivityThread.handleStopActivity   
TransactionExecutor.java:192android.app.servertransaction.TransactionExecutor.performLifecycleSequence  
TransactionExecutor.java:165android.app.servertransaction.TransactionExecutor.cycleToPath   
TransactionExecutor.java:142android.app.servertransaction.TransactionExecutor.executeLifecycleState 
TransactionExecutor.java:70android.app.servertransaction.TransactionExecutor.execute    
ActivityThread.java:1947android.app.ActivityThread$H.handleMessage  
Handler.java:106android.os.Handler.dispatchMessage  
Looper.java:214android.os.Looper.loop   
ActivityThread.java:7032android.app.ActivityThread.main 
Method.java:-2java.lang.reflect.Method.invoke   
RuntimeInit.java:494com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run 
ZygoteInit.java:965com.android.internal.os.ZygoteInit.main
bsadiwala commented 5 years ago

If you are calling Marketo's 'onStop()/onActivityStopped' method in your application. Then you can remove these methods now as it won't required in SDK version 0.8.0, and we have already updated it on our developer document (https://developers.marketo.com/mobile/installation/#android_sdk_installation).

ColtonIdle commented 5 years ago

We're not calling onStop() anywhere. We use Marketo for a very limited use case in our app.

We call Marketo.reportAction(event, meta); often and we call Marketo.getInstance(requireContext()).associateLead(lead) once.

ColtonIdle commented 5 years ago

Bump

bsadiwala commented 5 years ago

We are looking into the issue. @ColtonIdle If possible, can you please share the application with us, it will help us to debug better.

ColtonIdle commented 5 years ago

Thanks for confirming that you're looking into it. I can't share the application details, but I can share some other details such as the device.

batteryLevel 0.62 brand samsung charging false cpuAbi [ "arm64-v8a", "armeabi-v7a", "armeabi" ] dpi 480 emulator false freeDisk 57205981184 freeMemory 264105032 id 11208de3-9863-44c4-9a8e-5fe1f51ccb0a jailbroken false locale en_US locationStatus allowed manufacturer samsung model SM-G950U networkAccess wifi orientation portrait osName android osVersion 8.0.0 runtimeVersions { "androidApiLevel": "26", "osBuild": "R16NW.G950USQS5CSB1" } screenDensity 3 screenResolution 2076x1080 time 2019-05-07T02:10:54.000Z totalMemory 268435456

bsadiwala commented 5 years ago

Ok @ColtonIdle Thank you for providing the information. I will debug based on this and get back to you once it is fixed.

ColtonIdle commented 5 years ago

The original report was from Bugsnag, but there's a similar one from the Play console.

Samsung Galaxy S8 (dreamqltesq), Android 8.0

"main" tid=1 Blocked 
"main" prio=5 tid=1 Blocked
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x733ea100 self=0x7b526c4a00
  | sysTid=30225 nice=-10 cgrp=default sched=0/0 handle=0x7b57af29c8
  | state=S schedstat=( 944699744 235098167 2882 ) utm=63 stm=31 core=0 HZ=100
  | stack=0x7fbff67000-0x7fbff69000 stackSize=8MB
  | held mutexes=
  at com.marketo.Marketo.b (SourceFile:20822)
- waiting to lock <0x02f81912> (a com.marketo.Marketo) held by thread 29
  at com.marketo.Marketo$a.onActivityStopped (SourceFile:947)
  at android.app.Application.dispatchActivityStopped (Application.java:258)
  at android.app.Activity.onStop (Activity.java:1921)
  at androidx.fragment.app.FragmentActivity.onStop (FragmentActivity.java:541)
  at androidx.appcompat.app.AppCompatActivity.onStop (AppCompatActivity.java:185)
  at com.myapp.Base.onStop (Base.java:95)
bsadiwala commented 5 years ago

Please try putting delay (100/200ms) while calling "reportAction()" & "associateLead()" method, so it must call after initialization of SDK. If it fix your issue then we will update the SDK in next release.

ColtonIdle commented 5 years ago

Are you saying that associateLead() and reportAction() must be called synchronously? Or are you saying that associateLead() HAS to complete before any reportAction() can be called? Or is it something else?

I'm just trying to understand what the problem is before I introduce an artificial delay on the main thread of my application.

bsadiwala commented 5 years ago

No, I am saying that initializeSDK(munchkinId,appSecretKey) method should be called before associateLead () & reportAction().

ColtonIdle commented 5 years ago

Okay.

In my case, I'm already calling initializeSDK(munchkinId,appSecretKey) before associateLead() & reportAction().

You want me to add an artificial delay after initializeSDK(munchkinId,appSecretKey)? If so, I'm not sure if that will be approved on my team as initializeSDK(munchkinId,appSecretKey) is called in our App.onCreate() so adding a delay there will delay the main thread.

bsadiwala commented 5 years ago

You can try putting associateLead () & reportAction() methods in runnable to avoid ANR.

Handler mHandler = new Handler(); mHandler.postDelayed(new Runnable() { @Override public void run() { Marketo.reportAction(reportAction,meta); } },100);

ColtonIdle commented 5 years ago

Ran this by my team and we decided that we don't want to go this route as it's pretty hacky. We hope that you agree.

Can the Marketo team fix this so that the SDK doesn't cause ANRs?

bsadiwala commented 5 years ago

Sure.

As here we are not able to reproduce it, So just want to confirm with you that you see this ANR in production and play console & Bugsnag tools are showing this report?

Are you also able to reproduce ANR in debug build on your system?

ColtonIdle commented 5 years ago

Yes. We got the crash in two places. BugSnag and Play Console.

We just added Marketo 0.8.0 so I don't know if earlier versions had this problem.

bsadiwala commented 5 years ago

Is your application is free on play store? If yes, then can you please share me the play store url of the application. So i can download the app and check if something i can debug.

ColtonIdle commented 5 years ago

Can't release that information. Sorry

bsadiwala commented 5 years ago

Please reach out to this support channel for the help. https://www.marketo.com/why-marketo/services-and-support/support/