customerio / customerio-android

This is the official Customer.io SDK for Android.
MIT License
11 stars 9 forks source link

ANR in EngineWebView initialization #361

Open remi-ollivier opened 2 weeks ago

remi-ollivier commented 2 weeks ago

SDK version: 3.8.1

Environment: Production

Are logs available?

#00  pc 0x0000000001c03f7c  [anon:libwebview reservation]
  #01  pc 0x0000000002691133  [anon:libwebview reservation]
  #02  pc 0x000000000002cbad  /apex/com.android.runtime/bin/linker (__dl__ZL10call_arrayIPFviPPcS1_EEvPKcPT_jbS5_+204)
  #03  pc 0x000000000001ffee  [anon:linker_alloc]
  at android.webkit.WebViewLibraryLoader.nativeLoadWithRelroFile (Native method)
  at android.webkit.WebViewLibraryLoader.loadNativeLibrary (WebViewLibraryLoader.java:214)
  at android.webkit.WebViewFactory.getProviderClass (WebViewFactory.java:427)
  at android.webkit.WebViewFactory.getProvider (WebViewFactory.java:262)
  at android.webkit.WebView.getFactory (WebView.java:2576)
  at android.webkit.WebView.ensureProviderCreated (WebView.java:2570)
  at android.webkit.WebView.setOverScrollMode (WebView.java:2638)
  at android.view.View.<init> (View.java:5363)
  at android.view.View.<init> (View.java:5515)
  at android.view.ViewGroup.<init> (ViewGroup.java:702)
  at android.widget.AbsoluteLayout.<init> (AbsoluteLayout.java:56)
  at android.webkit.WebView.<init> (WebView.java:413)
  at android.webkit.WebView.<init> (WebView.java:355)
  at android.webkit.WebView.<init> (WebView.java:337)
  at android.webkit.WebView.<init> (WebView.java:324)
  at android.webkit.WebView.<init> (WebView.java:314)
  at io.customer.messaginginapp.gist.presentation.engine.EngineWebView.<init> (EngineWebView.kt:34)
  at io.customer.messaginginapp.gist.presentation.engine.EngineWebView.<init> (EngineWebView.kt:20)
  at io.customer.messaginginapp.gist.presentation.GistView.<init> (GistView.kt:27)
  at io.customer.messaginginapp.gist.presentation.GistSdk.init$lambda$0 (GistSdk.kt:106)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:223)
  at android.app.ActivityThread.main (ActivityThread.java:7989)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:635)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:947)

Describe the bug

Customers are facing ANRs, it happens on all Android version that we support, several phone brands and models. It happens 25% of the time in background and 75% in foreground. The stacktrace doesn't show any call from within our app, it looks like your SDK is trying to initialize a webview and this is the root cause of the ANR

To Reproduce

No idea, happens only in production, we couldn't reproduce this one

Expected behavior

Do you have any way to handle this case and update your SDK to fix ANRs? This would be very appreciated. Thanks!

Shahroz16 commented 2 weeks ago

Hey @remi-ollivier, thank you for brining this to our attention and apologies that you faced this. We have noted it and will try to find and fix the root cause. We will let you know when the fix is out, appreciate your patience and support.

remi-ollivier commented 2 weeks ago

Thank you for handling it! I'm adding you another stacktrace as we have several different issues with quite the same trace. It's impacting us a lot as it's here 9 times in our top 30 ANRs.

 #00  pc 0x000000000004c4ac  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
  #01  pc 0x000000000023247c  /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks+140)
  #02  pc 0x000000000056b798  /apex/com.android.art/lib64/libart.so (art::JNI<false>::CallStaticVoidMethodV+2184)
  #03  pc 0x0000000002590ab8  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #04  pc 0x0000000004ed6f70  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #05  pc 0x000000000310bfa4  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #06  pc 0x00000000030e0bbc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #07  pc 0x00000000030d03fc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #08  pc 0x00000000030cfedc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #09  pc 0x00000000023035ec  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #10  pc 0x00000000031a12dc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #11  pc 0x00000000031a1200  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #12  pc 0x00000000031a1134  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #13  pc 0x0000000002febbcc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #14  pc 0x0000000002febb5c  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #15  pc 0x0000000002feb9d0  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #16  pc 0x0000000002feb7fc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #17  pc 0x000000000309c31c  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #18  pc 0x000000000309b644  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #19  pc 0x000000000309b2c0  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #20  pc 0x00000000038dfaa0  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #21  pc 0x00000000038e190c  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #22  pc 0x00000000038e1f10  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #23  pc 0x00000000038e323c  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #24  pc 0x000000000308a52c  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #25  pc 0x0000000001f43450  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  #26  pc 0x00000000045d52dc  /data/app/~~vXkJlpmHhSvQ7v7XbsarXQ==/com.google.android.webview-4QDoc-vJE1tcKjpr-45GIw==/base.apk (BuildId: f1523c2143f3cffb59f0a77874b91b6914e963a1)
  at J.N.M9iLjy6T (Native method)
  at org.chromium.content.browser.BrowserStartupControllerImpl.d (chromium-TrichromeWebViewGoogle.aab-stable-642216531:128)
  at WV.P5.run (chromium-TrichromeWebViewGoogle.aab-stable-642216531:198)
  at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:487)
  at java.util.concurrent.FutureTask.run (FutureTask.java:264)
  at org.chromium.base.task.PostTask.d (chromium-TrichromeWebViewGoogle.aab-stable-642216531:11)
  at org.chromium.android_webview.AwBrowserProcess.j (chromium-TrichromeWebViewGoogle.aab-stable-642216531:33)
  at com.android.webview.chromium.L.d (chromium-TrichromeWebViewGoogle.aab-stable-642216531:203)
  at com.android.webview.chromium.L.b (chromium-TrichromeWebViewGoogle.aab-stable-642216531:42)
  at com.android.webview.chromium.L.f (chromium-TrichromeWebViewGoogle.aab-stable-642216531:4)
  at com.android.webview.chromium.WebViewChromiumFactoryProvider.l (chromium-TrichromeWebViewGoogle.aab-stable-642216531:8)
  at com.android.webview.chromium.WebViewChromium.init (chromium-TrichromeWebViewGoogle.aab-stable-642216531:97)
  at android.webkit.WebView.<init> (WebView.java:443)
  at android.webkit.WebView.<init> (WebView.java:363)
  at android.webkit.WebView.<init> (WebView.java:345)
  at android.webkit.WebView.<init> (WebView.java:332)
  at android.webkit.WebView.<init> (WebView.java:322)
  at io.customer.messaginginapp.gist.presentation.engine.EngineWebView.<init> (EngineWebView.kt:34)
  at io.customer.messaginginapp.gist.presentation.engine.EngineWebView.<init> (EngineWebView.kt:20)
  at io.customer.messaginginapp.gist.presentation.GistView.<init> (GistView.kt:27)
  at io.customer.messaginginapp.gist.presentation.GistSdk.init$lambda$0 (GistSdk.kt:106)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:241)
  at android.os.Looper.loop (Looper.java:342)
  at android.app.ActivityThread.main (ActivityThread.java:8143)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:583)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1045)

Looking forward to hearing from you!

Shahroz16 commented 2 weeks ago

Hey @remi-ollivier, we have been looking into this, we are unable to reproduce it. While searching for similar issues on StackOverflow and other places, we do similar issues like webview causing ANR but in almost all cases it comes down to bug on the Chromium version being used on those phones. Here is the chromium-reported issues list specifying similar bugs.

Can you list some devices and SDK versions etc for the phones that are facing the ANRs and it might help us reproduce and solve it?

remi-ollivier commented 2 weeks ago

Hi. Thanks for your investigation @Shahroz16. I won't be able to give you the chromium versions installed on their phones. For Android versions we have Android SDK 29-30-31-33-34. For devices the list is quite long but we have Tecno-KH6, Nokia RNNA, Tecno-KJ5, Redmi fire, Infinix-X665E, Vivo 2111, Tecno-BF7, Tecno-KC8 etc Not sure it helps you a lot but let me know if I can provide you any other information that you need

Shahroz16 commented 2 weeks ago

Thanks for the additional information @remi-ollivier, but we can still not reproduce it. We are going to continue looking into how we can reproduce or find the root cause of it, meanwhile, if there is something else you find that can lead us that would be much appreciated.

But rest assured it is more of an intermittent chromium bug, we just need to see what can we do to bypass it.