Closed ZhangShuFly closed 4 years ago
Hi @ZhangShuFly,
We're going to need more information than this. Most important will be a full crashlog/ANR trace, but also it would help to know what version of the library you upgraded from, how you're using Airship location services in your app, whether there are specific android OS versions and devices seeing the crash, etc.
@marc-scig Thank you for your reply. ℹ I upgraded from 10.0.1 to 12.2.0. ℹ In my code, the only things about location are:
UAirship.shared (). locationManager.isLocationUpdatesEnabled = true
UAirship.shared (). locationManager.isBackgroundLocationAllowed = true
I'm sure there's no code for location other than that. ℹ From Android 5.0 to 10.0. Including Samsung, LG, moto and other devices ℹ Report: Today, 11:07 AM on app version 11000247 LGE LG Premier Pro (cv3), 2048MB RAM, Android 8.1 Report 1
COLLAPSE ALL "main" tid=1 Native "main" prio=5 tid=1 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x73acd4b8 self=0xad0af000 | sysTid=13781 nice=0 cgrp=default sched=0/0 handle=0xb187c4a4 | state=S schedstat=( 0 0 0 ) utm=43 stm=13 core=1 HZ=100 | stack=0xbe142000-0xbe144000 stackSize=8MB | held mutexes=
at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:325) at android.os.Looper.loop (Looper.java:151) at android.app.ActivityThread.main (ActivityThread.java:6724) 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:810) "Jit thread pool worker thread 0" tid=2 Native "Jit thread pool worker thread 0" daemon prio=5 tid=2 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc0198 self=0xad0afc00 | sysTid=13787 nice=9 cgrp=default sched=0/0 handle=0xa5807970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1 HZ=100 | stack=0xa5709000-0xa570b000 stackSize=1022KB | held mutexes=
"ReferenceQueueDaemon" tid=4 Waiting "ReferenceQueueDaemon" daemon prio=5 tid=4 Waiting | group="system" sCount=1 dsCount=0 flags=1 obj=0x14fc02a8 self=0xad0b0800 | sysTid=13789 nice=4 cgrp=default sched=0/0 handle=0x93340970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=3 HZ=100 | stack=0x9323e000-0x93240000 stackSize=1038KB | held mutexes= at java.lang.Object.wait (Native method)
"Profile Saver" tid=9 Native "Profile Saver" daemon prio=5 tid=9 Native | group="system" sCount=1 dsCount=0 flags=1 obj=0x14fc0550 self=0x9dbb3c00 | sysTid=13796 nice=9 cgrp=default sched=0/0 handle=0x92e2f970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=2 HZ=100 | stack=0x92d35000-0x92d37000 stackSize=1006KB | held mutexes=
"Binder:13781_2" tid=10 Native "Binder:13781_2" prio=5 tid=10 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc04c8 self=0x9dbb3000 | sysTid=13795 nice=0 cgrp=default sched=0/0 handle=0x92d2a970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=2 HZ=100 | stack=0x92c30000-0x92c32000 stackSize=1006KB | held mutexes=
"Queue" tid=12 Waiting "Queue" prio=10 tid=12 Waiting | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc0760 self=0x9dbb5a00 | sysTid=13804 nice=-8 cgrp=default sched=0/0 handle=0x90aff970 | state=S schedstat=( 0 0 0 ) utm=11 stm=0 core=0 HZ=100 | stack=0x909fd000-0x909ff000 stackSize=1038KB | held mutexes= at java.lang.Object.wait (Native method)
at libcore.io.Linux.android_getaddrinfo (Native method) at libcore.io.ForwardingOs.android_getaddrinfo (ForwardingOs.java:59) at java.net.Inet6AddressImpl.lookupHostByName (Inet6AddressImpl.java:122) at java.net.Inet6AddressImpl.lookupAllHostAddr (Inet6AddressImpl.java:90) at java.net.InetAddress.getAllByName (InetAddress.java:787) at com.android.okhttp.Dns$1.lookup (Dns.java:39) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress (RouteSelector.java:175) at com.android.okhttp.internal.http.RouteSelector.nextProxy (RouteSelector.java:141) at com.android.okhttp.internal.http.RouteSelector.next (RouteSelector.java:83) at com.android.okhttp.internal.http.StreamAllocation.findConnection (StreamAllocation.java:174) at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection (StreamAllocation.java:126) at com.android.okhttp.internal.http.StreamAllocation.newStream (StreamAllocation.java:95) at com.android.okhttp.internal.http.HttpEngine.connect (HttpEngine.java:314) at com.android.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:257) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:478) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:424) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode (HttpURLConnectionImpl.java:555) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode (DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode (HttpsURLConnectionImpl.java) at com.facebook.GraphResponse.fromHttpConnection (GraphResponse.java:264) at com.facebook.GraphRequest.executeConnectionAndWait (GraphRequest.java:1282) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1180) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1146) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1130) at com.facebook.GraphRequest.executeAndWait (GraphRequest.java:1105) at com.facebook.GraphRequest.executeAndWait (GraphRequest.java:999) at com.facebook.internal.FetchedAppSettingsManager.getAppSettingsQueryResponse (FetchedAppSettingsManager.java:375) at com.facebook.internal.FetchedAppSettingsManager.queryAppSettings (FetchedAppSettingsManager.java:281) at com.facebook.UserSettingsManager$1.run (UserSettingsManager.java:151) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764) "AsyncTask #2" tid=22 Native "AsyncTask #2" prio=5 tid=22 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc1988 self=0x9dbdc200 | sysTid=13822 nice=0 cgrp=default sched=0/0 handle=0x8fce2970 | state=S schedstat=( 0 0 0 ) utm=2 stm=0 core=1 HZ=100 | stack=0x8fbe0000-0x8fbe2000 stackSize=1038KB | held mutexes=
at libcore.io.Linux.android_getaddrinfo (Native method) at libcore.io.ForwardingOs.android_getaddrinfo (ForwardingOs.java:59) at java.net.Inet6AddressImpl.lookupHostByName (Inet6AddressImpl.java:122) at java.net.Inet6AddressImpl.lookupAllHostAddr (Inet6AddressImpl.java:90) at java.net.InetAddress.getAllByName (InetAddress.java:787) at com.android.okhttp.Dns$1.lookup (Dns.java:39) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress (RouteSelector.java:175) at com.android.okhttp.internal.http.RouteSelector.nextProxy (RouteSelector.java:141) at com.android.okhttp.internal.http.RouteSelector.next (RouteSelector.java:83) at com.android.okhttp.internal.http.StreamAllocation.findConnection (StreamAllocation.java:174) at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection (StreamAllocation.java:126) at com.android.okhttp.internal.http.StreamAllocation.newStream (StreamAllocation.java:95) at com.android.okhttp.internal.http.HttpEngine.connect (HttpEngine.java:314) at com.android.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:257) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:478) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:424) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode (HttpURLConnectionImpl.java:555) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode (DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode (HttpsURLConnectionImpl.java) at com.facebook.GraphResponse.fromHttpConnection (GraphResponse.java:264) at com.facebook.GraphRequest.executeConnectionAndWait (GraphRequest.java:1282) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1180) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1146) at com.facebook.GraphRequest.executeBatchAndWait (GraphRequest.java:1130) at com.facebook.GraphRequest.executeAndWait (GraphRequest.java:1105) at com.facebook.GraphRequest.executeAndWait (GraphRequest.java:999) at com.facebook.internal.FetchedAppSettingsManager.getAppSettingsQueryResponse (FetchedAppSettingsManager.java:375) at com.facebook.internal.FetchedAppSettingsManager.access$100 (FetchedAppSettingsManager.java:63) at com.facebook.internal.FetchedAppSettingsManager$1.run (FetchedAppSettingsManager.java:179) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) at java.lang.Thread.run (Thread.java:764) "pool-4-thread-1" tid=23 TimedWaiting "pool-4-thread-1" prio=5 tid=23 TimedWaiting | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc1eb8 self=0x9dbdc800 | sysTid=13826 nice=0 cgrp=default sched=0/0 handle=0x8fbdd970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=2 HZ=100 | stack=0x8fadb000-0x8fadd000 stackSize=1038KB | held mutexes= at java.lang.Object.wait (Native method)
at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:325) at android.os.Looper.loop (Looper.java:151) at android.os.HandlerThread.run (HandlerThread.java:65) "background" tid=33 Native "background" prio=5 tid=33 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc2d30 self=0x9dbdaa00 | sysTid=13842 nice=0 cgrp=default sched=0/0 handle=0x8f1ab970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100 | stack=0x8f0a9000-0x8f0ab000 stackSize=1038KB | held mutexes=
at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:325) at android.os.Looper.loop (Looper.java:151) at android.os.HandlerThread.run (HandlerThread.java:65) at com.urbanairship.util.AirshipHandlerThread.run (AirshipHandlerThread.java:27) "location" tid=34 Native "location" prio=5 tid=34 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc2e18 self=0x9da5e000 | sysTid=13843 nice=0 cgrp=default sched=0/0 handle=0x8f0a6970 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100 | stack=0x8efa4000-0x8efa6000 stackSize=1038KB | held mutexes=
at android.os.MessageQueue.nativePollOnce (Native method) at android.os.MessageQueue.next (MessageQueue.java:325) at android.os.Looper.loop (Looper.java:151) at android.os.HandlerThread.run (HandlerThread.java:65) at com.urbanairship.util.AirshipHandlerThread.run (AirshipHandlerThread.java:27) "UrbanAirship#2" tid=35 Native "UrbanAirship#2" prio=5 tid=35 Native | group="main" sCount=1 dsCount=0 flags=1 obj=0x14fc2f00 self=0x9da5e600 | sysTid=13844 nice=0 cgrp=default sched=0/0 handle=0x8efa1970 | state=S schedstat=( 0 0 0 ) utm=0 stm=3 core=0 HZ=100 | stack=0x8ee9f000-0x8eea1000 stackSize=1038KB | held mutexes=
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake (Native method) at com.android.org.conscrypt.SslWrapper.doHandshake (SslWrapper.java:374) at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake (ConscryptFileDescriptorSocket.java:217) at com.android.okhttp.internal.io.RealConnection.connectTls (RealConnection.java:283) at com.android.okhttp.internal.io.RealConnection.connectSocket (RealConnection.java:156) at com.android.okhttp.internal.io.RealConnection.connect (RealConnection.java:119) at com.android.okhttp.internal.http.StreamAllocation.findConnection (StreamAllocation.java:184) at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection (StreamAllocation.java:126) at com.android.okhttp.internal.http.StreamAllocation.newStream (StreamAllocation.java:95) at com.android.okhttp.internal.http.HttpEngine.connect (HttpEngine.java:314) at com.android.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:257) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:478) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:424) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode (HttpURLConnectionImpl.java:555) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode (DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode (HttpsURLConnectionImpl.java) at com.urbanairship.http.Request.execute (Request.java:211) at com.urbanairship "Signal Catcher" tid=3 Runnable "Signal Catcher" daemon prio=5 tid=3 Runnable | group="system" sCount=0 dsCount=0 flags=0 obj=0x14fc0220 self=0xad0b0200 | sysTid=13788 nice=0 cgrp=default sched=0/0 handle=0xa5706970 | state=R schedstat=( 0 0 0 ) utm=2 stm=2 core=1 HZ=100 | stack=0xa560c000-0xa560e000 stackSize=1006KB | held mutexes= "mutator lock"(shared held)
"HeapTaskDaemon" tid=6 Blocked "HeapTaskDaemon" daemon prio=5 tid=6 Blocked | group="system" sCount=1 dsCount=0 flags=1 obj=0x14fc4f48 self=0x9da1b600 | sysTid=13792 nice=4 cgrp=default sched=0/0 handle=0x93031970 | state=S schedstat=( 0 0 0 ) utm=9 stm=0 core=1 HZ=100 | stack=0x92f2f000-0x92f31000 stackSize=1038KB | held mutexes=
at dalvik.system.VMRuntime.runHeapTasks (Native method)
ℹ Because I can't reproduce this issue, there's no more information for you.
@ZhangShuFly This is a background ANR probably due to the broadcast receiver not finishing in time. Broadcasts start the entire app, not just our SDK, so anything that changed that starts in Application.onCreate could also be the cause of the ANR. The Airship LocationReceiver does most its work on a background thread but still has to finish the intent on time. How are you calling takeOff? What work are you doing in the onAirshipReady callback?
@rlepinski ℹI call UAirship.takeOff in Application.onCreate(). ℹ onAirshipReady callback code:
`
fun configAirship()
{
UAirship.takeOff(application) { airship ->
if(airship == null) return@takeOff
airship.pushManager.setNotificationFactory(CustomNotificationFactory(application))
airship.pushManager.addRegistrationListener(SampleRegistrationListener())
UAirship.shared().locationManager.isLocationUpdatesEnabled = true
UAirship.shared().locationManager.isBackgroundLocationAllowed = true
enablePushNotification(true)
}
}
fun enablePushNotification(enabled: Boolean)
{
UAirship.shared().pushManager.apply {
isSoundEnabled = enabled
isVibrateEnabled = enabled
isPushEnabled = enabled
userNotificationsEnabled = enabled
}
UAirship.shared().locationManager.isLocationUpdatesEnabled = enabled
if (enabled)
{
sendTagsToServer()
}
}
fun sendTagsToServer()
{
val allTags = LinkedHashSet<String>()
...
UAirship.shared().pushManager.tags = allTags
}
`
ℹ Application.onCreate and onairshipready callback are unchanged from the previous version .But Google play console shows a lot of new ANRS related to LocationReceiver. The only thing I can think of is that I upgraded 10.0.1 to 12.2.0.
Could you expand the sendTagsToServer
method?
I'm sure there are no time-consuming tasks in sendtagstoserver. `
/**
* Set tags to Airship
*/
@Synchronized
fun sendTagsToServer()
{
val allTags = LinkedHashSet<String>()
allTags.add("N_ALL")
var tagUser = "U_ANONYMOUS"
if (isLogin())
{
allTags.add("U_LOGGEDIN")
tagUser = "U_MVPD"
}
allTags.add(tagUser)
val carrier = Build.BRAND
if (!TextUtils.isEmpty(carrier))
{
allTags.add("U_CARRIER_" + carrier.toUpperCase())
}
val region = getDefaultRegionName()
allTags.add(String.format("U_REGION_%s", region.trim().toUpperCase().replace(" ", "_")))
UAirship.shared().pushManager.tags = allTags
}
/**
* from SharedPreferences
*/
fun isLogin(): Boolean
{
return ShareDataManager.NLShareData.getPreferenceBoolean(Constants.PROVIDER_LOGIN_STATE, false)
}
/**
* ‘configs’ is a global variable object
*/
fun getDefaultRegionName(): String {
return Config.configs?.getRegionName() ?: "East"
}
`
The only location code that changed from 10.x to 12.x was androidx migration. I am almost certain it has to do with the amount of work your application is doing during onCreate, making it take too long to process the intent. We had similar issues with apps taking too long to process notifications causing background ANRs. We can deploy the same solution where we finish the broadcast in 10 seconds even if the work is not done yet, making it possible for the OS to suspend the process before we fully process the location.
ℹ Thanks. Besides to do a lot of work in Application.onCreate, do you think there are any other possible reasons? Has anyone else reported an issue similar to mine? Usually the onCteate method will be executed soon, I haven't thought when it will be blocked.
ℹ I reappeared this ANR when the app started today. Please help me to have a look. The app has been started normally, the ANR prompt appears on the MainActivity page. Attach trace and log: anr_2020-06-16-10-59-54-312.txt logcat.txt
ℹI checked the 10. x and 12. x codes. Version 10.x uses LocationService, and version 12.x changes to LocationReceiver. LocationReceiver.onReceive using goAsync, but UAirship.waitForTakeOff uses synchronized . If more than one broadcast in a short time, is it possible for ANR to occur?
It will only wait once, after its initialized then it will return early every time. There should be no reason for it take more than 100 ms in normal circumstances, so again I think it either has to be something in your application or doing some blocking in onAirshipReady. We did have it waiting up to 9 seconds, so if your process takes that long to initialize then we would only have 1 second to process the request.
I would recommend looking at your application startup time and trying to see how long it takes in various network conditions.
We released SDK 13.2 that will finish the broadcast early even if the update is not fully processed. This will prevent the background ANR but its possible the location update could get dropped if the OS suspends the process.
❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].
Preliminary Info
What Airship dependencies are you using?
ℹ com.urbanairship.android:urbanairship-fcm:12.2.0
What are the versions of any relevant development tools you are using?
ℹ Android Studio
Report
What unexpected behavior are you seeing?
ℹ Upgrade to urbanairship- fcm:12.2.0 After that, from the Google play console, we can see that the rate of ANR is rising rapidly, which is mainly caused by locationreceive.
What is the expected behavior?
ℹLow ANR
What are the steps to reproduce the unexpected behavior?
Do you have logging for the issue?
ℹ Broadcast of Intent { act=com.urbanairship.location.ACTION_LOCATION_UPDATE flg=0x10 cmp=com.jason.android/com.urbanairship.location.LocationReceiver (has extras) }