Reputation: 207
An ANR is getting reported on Google Play Console. After analyzing the stacktrace it points towards a method which is called after onInflate of Navigation Component. Following is the StackTrace.
"main" tid=1 Native
#00 pc 0x0000000000089cd0 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
#01 pc 0x000000000008dab4 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex_owner(void volatile*, bool, int, bool, timespec const*, unsigned int)+432)
#02 pc 0x00000000000f5314 /apex/com.android.runtime/lib64/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*)+252)
#03 pc 0x0000000000078890 /apex/com.android.runtime/lib64/bionic/libc.so (je_malloc_mutex_lock_slow+188)
#04 pc 0x0000000000059344 /apex/com.android.runtime/lib64/bionic/libc.so (je_arena_malloc_hard+124)
#05 pc 0x000000000004e2e4 /apex/com.android.runtime/lib64/bionic/libc.so (je_malloc+1668)
#06 pc 0x0000000000045c80 /apex/com.android.runtime/lib64/bionic/libc.so (malloc+40)
#07 pc 0x000000000004ef54 /system/lib64/libc++.so (operator new(unsigned long)+24)
#08 pc 0x000000000009a53c /system/lib64/libc++.so (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__grow_by_and_replace(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, char const*)+156)
#09 pc 0x000000000009a440 /system/lib64/libc++.so (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)+100)
#10 pc 0x00000000000699c0 /system/lib64/libandroidfw.so (android::ToFormattedResourceString(android::AssetManager2::ResourceName*)+296)
#11 pc 0x0000000000121720 /system/lib64/libandroid_runtime.so (android::NativeGetResourceName(_JNIEnv*, _jclass*, long, int)+104)
at android.content.res.AssetManager.nativeGetResourceName (Native method)
at android.content.res.AssetManager.getResourceName (AssetManager.java:762)
at android.content.res.ResourcesImpl.getResourceName (ResourcesImpl.java:331)
at android.content.res.Resources.getResourceName (Resources.java:2294)
at androidx.navigation.NavDestination$Companion.getDisplayName (NavDestination.kt:659)
at androidx.navigation.NavDestination.onInflate (NavDestination.kt:160)
at androidx.navigation.fragment.FragmentNavigator$Destination.onInflate (FragmentNavigator.kt:291)
at androidx.navigation.NavInflater.inflate (NavInflater.kt:88)
at androidx.navigation.NavInflater.inflate (NavInflater.kt:114)
at androidx.navigation.NavInflater.inflate (NavInflater.kt:64)
at androidx.navigation.NavController.setGraph (NavController.java:1039)
at androidx.navigation.fragment.NavHostFragment.onCreate (NavHostFragment.kt:155)
at androidx.fragment.app.Fragment.performCreate (Fragment.java:3094)
at androidx.fragment.app.FragmentStateManager.create (FragmentStateManager.java:504)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:268)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView (FragmentLayoutInflaterFactory.java:142)
at androidx.fragment.app.FragmentController.onCreateView (FragmentController.java:136)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView (FragmentActivity.java:247)
at androidx.fragment.app.FragmentActivity.onCreateView (FragmentActivity.java:226)
at android.view.LayoutInflater.tryCreateView (LayoutInflater.java:1124)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:1052)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:1016)
at android.view.LayoutInflater.rInflate (LayoutInflater.java:1178)
at android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:1139)
at android.view.LayoutInflater.inflate (LayoutInflater.java:696)
at android.view.LayoutInflater.inflate (LayoutInflater.java:548)
at android.view.LayoutInflater.inflate (LayoutInflater.java:495)
On the top of StackTrace it points towards a method inside the Navigation Component library. Following is the code.
@JvmStatic
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public fun getDisplayName(context: Context, id: Int): String {
// aapt-generated IDs have the high byte nonzero,
// so anything below that cannot be a valid resource id
return if (id <= 0x00FFFFFF) {
id.toString()
} else try {
context.resources.getResourceName(id)
} catch (e: Resources.NotFoundException) {
id.toString()
}
}
This method is getting called multiple times during the inflation of NavGraph, which is causing ANR because triggers the blocking chain (nativeGetResourceName → ToFormattedResourceString → je_malloc), involving disk I/O and
Upvotes: 0
Views: 32