flutter_inappwebview icon indicating copy to clipboard operation
flutter_inappwebview copied to clipboard

ANR issue in production android app

Open marcqtan opened this issue 3 years ago โ€ข 27 comments

Environment

Technology Version
Flutter version 2.2.2
Plugin version 5.3.2
Android version 10
iOS version NA
Xcode version NA

Device information:

Android Device: Android 10 (SDK 29) Sony Xperia XZ3

Description

During launch of the app, it will only show a white screen. This is happening in production and was reported by users. Only work around is to restart the app. I cannot reproduce this on my end.

I cannot repro it on my end so I looked at the Playstore Vital Reports.

Expected behavior:

No ANR No whitescreen.

Current behavior: White screen only during app start. ANR is happening

Steps to reproduce

  1. Open the app
  2. It will not go through
  3. Will only show whitescreen

Images

Stacktrace/Logcat

trace below:

#00  pc 0000000001a00674  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 00000000024025e0  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002103f70  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002106374  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 00000000017b7af0  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002e10cf0  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002e10ad4  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002e0f4ec  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (???)
 #00  pc 0000000002e100ac  /data/app/com.google.android.webview-NX370BtKX9xVdllmWZwsEQ==/base.apk!libmonochrome.so (Java_J_N_M1Y_1XVCN+120)
 at J.N.M1Y_XVCN (Native method)
 at org.chromium.content.browser.BrowserStartupControllerImpl.a (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at org.chromium.content.browser.BrowserStartupControllerImpl.g (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at C8.run (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at org.chromium.base.ThreadUtils.f (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at TA0.g (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at TA0.b (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at com.android.webview.chromium.WebViewChromiumFactoryProvider.getWebStorage (chromium-TrichromeWebViewGoogle.aab-stable-463807433)
 at android.webkit.WebStorage.getInstance (WebStorage.java:194)
 at com.pichillilorenzo.flutter_inappwebview.MyWebStorage.<init> (MyWebStorage.java:29)
 at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:89)
 at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:68)
 at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add (FlutterEngineConnectionRegistry.java:143)
 at io.flutter.plugins.GeneratedPluginRegistrant.registerWith (GeneratedPluginRegistrant.java:24)
 at java.lang.reflect.Method.invoke (Native method)
 at io.flutter.embedding.engine.FlutterEngine.registerPlugins (FlutterEngine.java:414)
 at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:345)
 at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:260)
 at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:240)
 at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:160)
 at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:151)
 at com.ryanheise.audioservice.AudioServicePlugin.getFlutterEngine (AudioServicePlugin.java:68)
 at com.ryanheise.audioservice.AudioService.onCreate (AudioService.java:286)
 at android.app.ActivityThread.handleCreateService (ActivityThread.java:4273)
 at android.app.ActivityThread.access$1900 (ActivityThread.java:239)
 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2029)
 at android.os.Handler.dispatchMessage (Handler.java:107)
 at android.os.Looper.loop (Looper.java:214)
 at android.app.ActivityThread.main (ActivityThread.java:7899)
 at java.lang.reflect.Method.invoke (Native method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:960)

#855

marcqtan avatar Nov 16 '21 04:11 marcqtan

๐Ÿ‘‹ @marcqtan

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

github-actions[bot] avatar Nov 16 '21 04:11 github-actions[bot]

same issue

Gurvinder963 avatar Apr 14 '22 15:04 Gurvinder963

Me too.๐Ÿ˜“ I'm looking for a solution.

Yokoi-K avatar Apr 15 '22 01:04 Yokoi-K

@Gurvinder963 @marcqtan

I have a question for you both.

What are the circumstances when this error occurs?

I noticed this error during a replacement update from TWA to Flutter. Are you two in a situation where you are doing replacements, etc. from TWA? Or have you been a Flutter project from the beginning?

thanks๐Ÿ™

Yokoi-K avatar Apr 15 '22 02:04 Yokoi-K

Also, the error I am experiencing with you guys is slightly different from my app.

However, I am experiencing ANR as well.

  at Tf0.setServiceWorkerClient (chromium-TrichromeWebViewGoogle.aab-stable-489607933:58)
  at androidx.webkit.internal.ServiceWorkerControllerImpl.setServiceWorkerClient (ServiceWorkerControllerImpl.java:88)
  at com.pichillilorenzo.flutter_inappwebview.ServiceWorkerManager.<init> (ServiceWorkerManager.java:41)
  at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:91)
  at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:68)
  at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add (FlutterEngineConnectionRegistry.java:145)
  at io.flutter.plugins.GeneratedPluginRegistrant.registerWith (GeneratedPluginRegistrant.java:104)
  at java.lang.reflect.Method.invoke (Native method)
  at io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister.registerGeneratedPlugins (GeneratedPluginRegister.java:80)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:355)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:263)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:243)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:163)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:154)
  at com.ryanheise.audioservice.AudioServicePlugin.getFlutterEngine (AudioServicePlugin.java:73)
  at jp.winticket.app.MainActivity.provideFlutterEngine (MainActivity.kt:10)
  at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine (FlutterActivityAndFragmentDelegate.java:248)
  at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach (FlutterActivityAndFragmentDelegate.java:174)
  at io.flutter.embedding.android.FlutterActivity.onCreate (FlutterActivity.java:459)
  at android.app.Activity.performCreate (Activity.java:8207)
  at android.app.Activity.performCreate (Activity.java:8191)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3819)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4022)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2336)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:246)
  at android.app.ActivityThread.main (ActivityThread.java:8653)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

Yokoi-K avatar Apr 15 '22 02:04 Yokoi-K

Hi,

flutter_inappwebview version - 4.0.0+4 Flutter - 1.22.5 Dart - 2.10.4

App is crashing while uploading app bundle on play store. It's crashing on Android 10 nd above.

But it's working fine in release apk. But now we can't upload apk on play store.

On Fri, 15 Apr, 2022, 7:55 am Yoko, @.***> wrote:

@Gurvinder963 https://github.com/Gurvinder963 @marcqtan https://github.com/marcqtan

I have a question for you both.

What are the circumstances when this error occurs?

I noticed this error during a replacement update from TWA to Flutter. Are you two in a situation where you are doing replacements, etc. from TWA? Or have you been a Flutter project from the beginning?

thanks๐Ÿ™

โ€” Reply to this email directly, view it on GitHub https://github.com/pichillilorenzo/flutter_inappwebview/issues/1032#issuecomment-1099791927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFE7L3LVVPKCD2QNYAJRYLVFDHPRANCNFSM5IDIW5GQ . You are receiving this because you were mentioned.Message ID: @.***>

Gurvinder963 avatar Apr 15 '22 14:04 Gurvinder963

Sorry, I still don't understand your statement.

Are you saying that the problem did not occur with the apk, but with the app bundle?

Another thing I'd like to ask is. Are you sure you are not replacing your TWA Android app with Flutter?

Yokoi-K avatar Apr 16 '22 03:04 Yokoi-K

Hi,

Yes, problem did not occur with the apk, but with the app bundle? Crashing in Android 10 and above.

I had not convert TWA to flutter. I created fresh flutter project.

I think I need to add

ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64:

I think plugin has native library so i have add above line .

flutter_youtube_player also crashing. I think it's using ur plugin internally.

On Sat, 16 Apr, 2022, 9:29 am Yoko, @.***> wrote:

Sorry, I still don't understand your statement.

Are you saying that the problem did not occur with the apk, but with the app bundle?

Another thing I'd like to ask is. Are you sure you are not replacing your TWA Android app with Flutter?

โ€” Reply to this email directly, view it on GitHub https://github.com/pichillilorenzo/flutter_inappwebview/issues/1032#issuecomment-1100559482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFE7L2R5A62EMXEL25BLLTVFI3LZANCNFSM5IDIW5GQ . You are receiving this because you were mentioned.Message ID: @.***>

Gurvinder963 avatar Apr 16 '22 05:04 Gurvinder963

https://github.com/pichillilorenzo/flutter_inappwebview/issues/1146#issue-1205705003

Sorry for the late reply.

Perhaps you are mistaken. The problem that occurred was a crash, right? I am experiencing ANR, not crashes.

Yokoi-K avatar Apr 18 '22 01:04 Yokoi-K

Hi,

Yes crash is happening on Android 11 when I target sdk 30 . Other wise it was working fine on target sdk 29.

flutter_inappwebview version - 4.0.0+4 Flutter - 1.22.5 Dart - 2.10.4

Should I have to update plugin?

On Mon, 18 Apr, 2022, 6:37 am Yoko, @.***> wrote:

#1146 (comment) https://github.com/pichillilorenzo/flutter_inappwebview/issues/1146#issue-1205705003

Sorry for the late reply.

Perhaps you are mistaken. The problem that occurred was a crash, right? I am experiencing ANR, not crashes.

โ€” Reply to this email directly, view it on GitHub https://github.com/pichillilorenzo/flutter_inappwebview/issues/1032#issuecomment-1100995859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFE7L45YWY4BWSGM72XJS3VFSYTNANCNFSM5IDIW5GQ . You are receiving this because you were mentioned.Message ID: @.***>

Gurvinder963 avatar Apr 18 '22 05:04 Gurvinder963

I don't know what to do.

I have moved to webview_flutter which is the problem and does not use ServiceWorker.

Yokoi-K avatar Apr 22 '22 09:04 Yokoi-K

@Yokoi-K how are you using the service worker controller? can you post the piece of code on how you initialize and use it? Also, post the full error stacktrace please

pichillilorenzo avatar Apr 22 '22 11:04 pichillilorenzo

No, we do not use ServiceWorker. I did not need it for my application. However, as you can see in this stack trace, there was an error in the ServiceWorker init. https://github.com/pichillilorenzo/flutter_inappwebview/issues/1032#issuecomment-1099793773

So I moved to webview_flutter which does not use service worker. However, this plugin was excellent and I would use it again if this error is fixed.

Yokoi-K avatar Apr 22 '22 12:04 Yokoi-K

@Yokoi-K that stacktrace is not full. Could you provide full stacktrace from the start please?

pichillilorenzo avatar Apr 22 '22 12:04 pichillilorenzo

Sorry, that stack trace is all there is. It is ANR, so there is no specific error statement.

Yokoi-K avatar Apr 22 '22 12:04 Yokoi-K

Ok, maybe I know how to fix that error

pichillilorenzo avatar Apr 22 '22 12:04 pichillilorenzo

@Yokoi-K I have uploaded the new version 5.4.0+3 that should not call setServiceWorkerClient method (that is the method that causes the error) if you are not using the Service Worker Controller in your Android app.

pichillilorenzo avatar Apr 22 '22 14:04 pichillilorenzo

Thank you!๐Ÿ™ The fixes were so fast, you're so good!

I will share this with my team.

Yokoi-K avatar Apr 22 '22 14:04 Yokoi-K

Hi @pichillilorenzo

We also have the same problem and here is the stack trace from the PlayConsole:

 #00  pc 000000000007f33c  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
  #00  pc 000000000014b094  /apex/com.android.runtime/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+148)
  #00  pc 00000000003b5940  /apex/com.android.runtime/lib64/libart.so (art::JNI::CallStaticIntMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+464)
  #00  pc 000000000354feb8  /data/app/com.google.android.webview--HMnghXDiUONnImlzY2YfQ==/base.apk!libmonochrome.so (???)
  at J.N.M1Y_XVCN (Native method)
  at org.chromium.content.browser.BrowserStartupControllerImpl.a (chromium-TrichromeWebViewGoogle.aab-stable-495106133:2377)
  at org.chromium.content.browser.BrowserStartupControllerImpl.f (chromium-TrichromeWebViewGoogle.aab-stable-495106133:256)
  at z8.run (chromium-TrichromeWebViewGoogle.aab-stable-495106133:168)
  at org.chromium.base.ThreadUtils.e (chromium-TrichromeWebViewGoogle.aab-stable-495106133:137)
  at org.chromium.android_webview.AwBrowserProcess.j (chromium-TrichromeWebViewGoogle.aab-stable-495106133:146)
  at com.android.webview.chromium.b1.d (chromium-TrichromeWebViewGoogle.aab-stable-495106133:228)
  at com.android.webview.chromium.b1.b (chromium-TrichromeWebViewGoogle.aab-stable-495106133:347)
  at com.android.webview.chromium.WebViewChromiumFactoryProvider.getWebStorage (chromium-TrichromeWebViewGoogle.aab-stable-495106133:504)
  at android.webkit.WebStorage.getInstance (WebStorage.java:194)
  at com.pichillilorenzo.flutter_inappwebview.MyWebStorage.<init> (MyWebStorage.java:29)
  at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:92)
  at com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin.onAttachedToEngine (InAppWebViewFlutterPlugin.java:71)
  at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add (FlutterEngineConnectionRegistry.java:145)
  at io.flutter.plugins.GeneratedPluginRegistrant.registerWith (GeneratedPluginRegistrant.java:104)
  at java.lang.reflect.Method.invoke (Native method)
  at io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister.registerGeneratedPlugins (GeneratedPluginRegister.java:80)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:355)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:263)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:243)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:163)
  at io.flutter.embedding.engine.FlutterEngine.<init> (FlutterEngine.java:154)
  at com.ryanheise.audioservice.AudioServicePlugin.getFlutterEngine (AudioServicePlugin.java:73)
  at com.ryanheise.audioservice.AudioService.onCreate (AudioService.java:282)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:3981)
  at android.app.ActivityThread.access$1600 (ActivityThread.java:226)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1900)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:214)
  at android.app.ActivityThread.main (ActivityThread.java:7386)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:980)

I am not sure, but it seems this ANR only happens at application startup. Can we try not to instantiate the WebStorage at the MyWebStorage constructor, but lazily instantiate it? https://github.com/pichillilorenzo/flutter_inappwebview/blob/ee1b0d7ff754a49e9f995c68505da3556b9c830d/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java#L29

lcdsmao avatar May 18 '22 06:05 lcdsmao

Hi @pichillilorenzo - As mentioned by @lcdsmao, we are also facing the same ANR issue

onkarmonks avatar Jul 20 '22 07:07 onkarmonks

Hi @pichillilorenzo, FYI - mentioned by @lcdsmao, we are also facing the same issue,

mohanK22 avatar Aug 19 '22 15:08 mohanK22

Hi @pichillilorenzo, do we have any update on this?

mohanK22 avatar Sep 02 '22 10:09 mohanK22

Hi @mohanK22 , have you tried to add this in the Manifest? 'android.permission.INTERNET' I have added the permission and problem solved

nickrivers avatar Sep 28 '22 09:09 nickrivers

Hi @nickrivers, The 'android.permission.INTERNET' permission is there in the manifest file which was added long back.

mohanK22 avatar Sep 29 '22 05:09 mohanK22

any news in this?

felipecastrosales avatar Mar 28 '23 18:03 felipecastrosales