我在很大程度上复制并粘贴了Google's official Consent SDK中的代码。
虽然大部分时间都没有任何问题,但有时会导致ANR。它正在成为ANR的主要原因。我假设必须在UI线程上运行ConsentForm.load。对此有补救措施吗?
ANR:
输入调度超时(等待发送非键事件,因为 触摸窗口尚未完成处理某些输入事件 超过500.0ms前送到它。等待队列长度:2。等待 队长年龄:6676.6ms。)
"main" tid=1 Native
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x74f5ef98 self=0xb8114c60
| sysTid=18557 nice=-4 cgrp=default sched=0/0 handle=0xb6f28b34
| state=S schedstat=( 1288189187 190774336 1785 ) utm=89 stm=39 core=0 HZ=100
| stack=0xbe594000-0xbe596000 stackSize=8MB
| held mutexes=
#00 pc 0000000000016a6c /system/lib/libc.so (syscall+28)
#01 pc 00000000000f60bb /system/lib/libart.so (_ZN3art17ConditionVariable4WaitEPNS_6ThreadE+82)
#02 pc 00000000003e4a23 /system/lib/libart.so (_ZN3artL12GoToRunnableEPNS_6ThreadE+502)
#03 pc 00000000000e56dd /system/lib/libart.so (_ZN3art12JniMethodEndEjPNS_6ThreadE+8)
#04 pc 0000000000183663 /data/app/com.google.android.webview-1/oat/arm/base.odex (Java_org_chromium_content_browser_framehost_NavigationControllerImpl_nativeLoadUrl__JLjava_lang_String_2IILjava_lang_String_2IILjava_lang_String_2Lorg_chromium_content_1public_common_ResourceRequestBody_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2ZZZ+342)
at org.chromium.content.browser.framehost.NavigationControllerImpl.nativeLoadUrl (NavigationControllerImpl.java)
at org.chromium.content.browser.framehost.NavigationControllerImpl.loadUrl (NavigationControllerImpl.java:67)
at org.chromium.android_webview.AwContents.loadUrl (AwContents.java:496)
at org.chromium.android_webview.AwContents.loadUrl (AwContents.java:375)
at org.chromium.android_webview.AwContents.loadUrl (AwContents.java:380)
at com.android.webview.chromium.WebViewChromium.loadUrl (WebViewChromium.java:227)
at android.webkit.WebView.loadUrl (WebView.java:894)
at com.google.ads.consent.ConsentForm.load (ConsentForm.java:271)