googleads-mobile-unity icon indicating copy to clipboard operation
googleads-mobile-unity copied to clipboard

A lot of ANR for Android 8.1 (SDK 27) when displaying Interstitials

Open adibacco opened this issue 4 years ago • 14 comments

[REQUIRED] Step 1: Describe your environment

  • Unity version: 2020.1.17f1
  • Google Mobile Ads Unity plugin version: 5.4.0
  • Platform: Android
  • Platform OS version: Android 8.1 (SDK 27)
  • Any specific devices issue occurs on: NONE
  • Mediation ad networks used, and their versions: NO

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Display Interstitial on Android 8.1 (SDK 27)

Main thread stack:

#00  pc 000000000013eba6  /system/lib/libart.so (art::DexFile::FindClassDef(art::dex::TypeIndex) const+33)
#00  pc 00000000001510ad  /system/lib/libart.so (art::DexFileVerifier::CheckInterClassDefItem()+964)
#00  pc 00000000001521c3  /system/lib/libart.so (art::DexFileVerifier::CheckInterSectionIterate(unsigned int, unsigned int, art::DexFile::MapItemType)+366)
#00  pc 000000000014ac11  /system/lib/libart.so (art::DexFileVerifier::Verify()+132)
#00  pc 000000000014aaa1  /system/lib/libart.so (art::DexFileVerifier::Verify(art::DexFile const*, unsigned char const*, unsigned int, char const*, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)+120)
#00  pc 000000000013de71  /system/lib/libart.so (art::DexFile::OpenOneDexFileFromZip(art::ZipArchive const&, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, art::DexFile::ZipOpenErrorCode*)+616)
#00  pc 000000000013d8e1  /system/lib/libart.so (art::DexFile::OpenAllDexFilesFromZip(art::ZipArchive const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>>>*)+268)
#00  pc 000000000013d5dd  /system/lib/libart.so (art::DexFile::OpenZip(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>>>*)+276)
#00  pc 000000000013d3a9  /system/lib/libart.so (art::DexFile::Open(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const>>>>*)+376)
#00  pc 000000000031efc7  /system/lib/libart.so (art::OatFileManager::OpenDexFilesFromOat(char const*, _jobject*, _jobjectArray*, art::OatFile const**, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>*)+3890)
#00  pc 00000000002ee249  /system/lib/libart.so (art::DexFile_openDexFileNative(_JNIEnv*, _jclass*, _jstring*, _jstring*, int, _jobject*, _jobjectArray*)+96)
#00  pc 0000000000051a43  /system/framework/arm/boot-core-libart.oat (Java_dalvik_system_DexFile_openDexFileNative__Ljava_lang_String_2Ljava_lang_String_2ILjava_lang_ClassLoader_2_3Ldalvik_system_DexPathList_00024Element_2+194)
at dalvik.system.DexFile.openDexFileNative (Native method)
at dalvik.system.DexFile.openDexFile (DexFile.java:353)
at dalvik.system.DexFile.<init> (DexFile.java:100)
at dalvik.system.DexFile.<init> (DexFile.java:74)
at dalvik.system.DexPathList.loadDexFile (DexPathList.java:374)
at dalvik.system.DexPathList.makeDexElements (DexPathList.java:337)
at dalvik.system.DexPathList.<init> (DexPathList.java:157)
at dalvik.system.BaseDexClassLoader.<init> (BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init> (PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader (ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader (ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader (ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader (ApplicationLoaders.java:35)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked (LoadedApk.java:693)
at android.app.LoadedApk.getClassLoader (LoadedApk.java:727)
at android.app.ContextImpl.getClassLoader (ContextImpl.java:300)
at android.webkit.WebViewFactory.getProviderClass (WebViewFactory.java:394)
at android.webkit.WebViewFactory.getProvider (WebViewFactory.java:194)
at android.webkit.WebView.getFactory (WebView.java:2530)
at android.webkit.WebView.ensureProviderCreated (WebView.java:2525)
at android.webkit.WebView.setOverScrollMode (WebView.java:2590)
at android.view.View.<init> (View.java:4574)
at android.view.View.<init> (View.java:4706)
at android.view.ViewGroup.<init> (ViewGroup.java:597)
at android.widget.AbsoluteLayout.<init> (AbsoluteLayout.java:55)
at android.webkit.WebView.<init> (WebView.java:643)
at android.webkit.WebView.<init> (WebView.java:588)
at android.webkit.WebView.<init> (WebView.java:571)
at android.webkit.WebView.<init> (WebView.java:558)
at android.webkit.WebView.<init> (WebView.java:548)
at com.google.android.gms.ads.internal.webview.ac.<init> (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1)
at com.google.android.gms.ads.internal.webview.s.a (unavailable)
at com.google.android.gms.ads.internal.util.bi.b (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:3)
at com.google.android.gms.ads.internal.webview.v.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:2)
at com.google.android.gms.ads.internal.js.l.<init> (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:4)
at com.google.android.gms.ads.internal.js.n.run (unavailable)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at ql.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected])
at com.google.android.gms.ads.internal.util.f.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1)
at ql.dispatchMessage (com.google.android.gms.policy_ads_fdr_dynamite@[email protected])
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6494)
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:807)

Relevant Code:

I suspect interstitial Show() method.

adibacco avatar Jan 08 '21 08:01 adibacco

Same problem here and also looks like other developers suffer from it:

https://forum.unity.com/threads/anr-input-dispatching-timed-out-in-google-play-console-how-to-identify-the-problem.983454/

We updated SDK to latest version but it still continues..

dghn avatar Jan 11 '21 07:01 dghn

+1

matthew-nc avatar Jan 29 '21 15:01 matthew-nc

+1

M-G-L avatar Feb 02 '21 14:02 M-G-L

+1

ybbwang avatar Feb 10 '21 16:02 ybbwang

I removed ADS for Android SDK 27, I removed also the initialization for SDK 27 and now the ANRs have gone. Please do something to improve the plugin.

adibacco avatar Feb 17 '21 16:02 adibacco

Hi @adibacco ,

Would you be able to share how you did this , please?

I have the same issue and I would love to use your workaround for SDK 27.

Thanks in advance! Best, John

I removed ADS for Android SDK 27, I removed also the initialization for SDK 27 and now the ANRs have gone. Please do something to improve the plugin.

M-G-L avatar Feb 24 '21 13:02 M-G-L

Getting the android api level is easy:


		string operatingSystem = SystemInfo.operatingSystem;
		try {
			androidApiLevel = int.Parse (operatingSystem.Substring(operatingSystem.IndexOf("API-") + 4, 2));
		} catch(Exception ex) {

		}
		Debug.Log("os " + SystemInfo.operatingSystem + " android api level " + androidApiLevel);

Then I have a gamobject that acts like an AdsManager in the initial scene and this object is started as "non active". After detecting that android api level is different from 27 (android 8.1) I decide to make the object active. The AdsManager object has a script that takes care of two main things:

  1. make the object not destroyable with
    void Awake()
    {
        GameObject[] objs = GameObject.FindGameObjectsWithTag("AdsManager");
        if (objs.Length > 1)
            Destroy(this.gameObject);
        
        DontDestroyOnLoad(this.gameObject);
    }

  1. Manage the AdMob initialisation with this code:
void Start() {
  if (androidApiLevel != 27  && androidApiLevel != 26) {
              MobileAds.SetiOSAppPauseOnBackground(true);
  
  
              // Configure TagForChildDirectedTreatment and test device IDs.
              RequestConfiguration requestConfiguration =
                  new RequestConfiguration.Builder()
                  .SetTagForChildDirectedTreatment(TagForChildDirectedTreatment.True)
                  .SetTestDeviceIds(deviceIds).build();
  
              MobileAds.SetRequestConfiguration(requestConfiguration);
  
              // Initialize the Google Mobile Ads SDK.
              MobileAds.Initialize(HandleInitCompleteAction);
          }
}

Hi @adibacco ,

Would you be able to share how you did this , please?

I have the same issue and I would love to use your workaround for SDK 27.

Thanks in advance! Best, John

I removed ADS for Android SDK 27, I removed also the initialization for SDK 27 and now the ANRs have gone. Please do something to improve the plugin.

adibacco avatar Feb 24 '21 13:02 adibacco

This issue has occurred for a long time and has not been fixed yet. I have been searching for it and saw that it must be related to some bugs in Android Webview in SDK 27 (All the ads sdk using webview to display ads). Maybe the device with Android 8.1 couldn't pull a remote update in the underlying webview implement so Google is unable to fix it.

hlongvu avatar Feb 26 '21 02:02 hlongvu

The same thing for me, are you going to fix it? Is this fix in your roadmap?

kapyar avatar Mar 03 '21 08:03 kapyar

I have the same issue, the workaround would cause a great loss of revenue as I have 1/3 of the active installs on these SDK versions. Please fix this Google!

AllanRW avatar Mar 26 '21 15:03 AllanRW

@stowy Can you have a look on this issue please?

AllanRW avatar Mar 26 '21 16:03 AllanRW

sorry mate I don't work there anymore. @Jillsong and @eleichtenschl would be best contacts to follow up.

On Sat, 27 Mar 2021, 2:01 am AllanRW, @.***> wrote:

@stowy https://github.com/stowy Can you have a look on this issue please?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googleads/googleads-mobile-unity/issues/1548#issuecomment-808332504, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNGOFFTLG4YPLMUJKVKBHDTFSVVVANCNFSM4V2EW33A .

stowy avatar Mar 27 '21 17:03 stowy

Just a workaround for those with high ANR rate, just remove the most problematic devices from Google Play console device catalog, the worst device is the Huawei Y5 Lite but you can find some others on your ANR list, by doing this I've reduced the ANR rate from 0.60% to 0.31% in a few days.

AllanRW avatar Jun 18 '21 15:06 AllanRW

I have the same issue; Please fix this Google!!! env: deps.play_services_ads = 'com.google.android.gms:play-services-ads-identifier:17.0.0' deps.play_services_location = 'com.google.android.gms:play-services-location:17.1.0' deps.play_services_ads_admob = 'com.google.android.gms:play-services-ads:20.6.0'

MotoMcLXL avatar May 16 '22 02:05 MotoMcLXL

Since there were no recent activities for this issue, we are therefore reluctantly going to close this bug for now.

If you are still experiencing the problem, please file a new issue with the same description, what happens and system / network tracing / Charles logs.

All system setups can be slightly different, so it's always better to open new issues and reference the related ones. Thanks for your contribution.

Note: We have introduced Optimize initialization and ad loading feature starting from plugin version 7.2.0. Please refer to the documentation for more details.

kunny avatar Feb 06 '23 14:02 kunny