gree / unity-webview

zlib License
2.26k stars 687 forks source link

ANR Problem Webview - Firebase + Webview #783

Open josemgmz opened 2 years ago

josemgmz commented 2 years ago

Hello,

I am constantly having ANR issues reported by Google Play on their analytics platform.

In this case, initially we thought it was a Firebase problem since some people had similar problems for unity firebase, so they recommended us to upgrade to the latest version of firebase, which we have done but the errors persist.

After digging a bit in the logs we found this:

Error Name: Input dispatching timed out (10d93b0 app.kokorokids.app/com.google.firebase.MessagingUnityPlayerActivity (server) is not responding. Waited 10001ms for MotionEvent)

Error Log: "main" prio=5 tid=1 Native

00 pc 0000000000086b8c /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)

00 pc 000000000008a938 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile, bool, int, bool, timespec const)+144)

00 pc 00000000000ec784 /apex/com.android.runtime/lib64/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t, bool, timespec const)+688)

00 pc 000000000017baa4 /data/app/~~s4LgLhlHDTFDqusDf7SmRw==/app.kokorokids.app-IdOQIEkINTdhy7aUZe2vqA==/lib/arm64/libunity.so (???)

00 pc 000000000017b958 /data/app/~~s4LgLhlHDTFDqusDf7SmRw==/app.kokorokids.app-IdOQIEkINTdhy7aUZe2vqA==/lib/arm64/libunity.so (UnitySendMessage+116)

00 pc 000000000034069c /data/app/~~s4LgLhlHDTFDqusDf7SmRw==/app.kokorokids.app-IdOQIEkINTdhy7aUZe2vqA==/lib/arm64/libunity.so (???)

at com.unity3d.player.UnityPlayer.nativeUnitySendMessage (Native method) at com.unity3d.player.UnityPlayer.UnitySendMessage (unavailable) at net.gree.unitywebview.CWebViewPluginInterface$1.run (CWebViewPluginInterface.java:90) at android.app.Activity.runOnUiThread (Activity.java:7154) at net.gree.unitywebview.CWebViewPluginInterface.call (CWebViewPluginInterface.java:88) at net.gree.unitywebview.CWebViewPlugin$2$2.onReceivedHttpError (CWebViewPlugin.java:295) at Pz.a (chromium-TrichromeWebViewGoogle.aab-stable-475810133:6) at A9.handleMessage (chromium-TrichromeWebViewGoogle.aab-stable-475810133:78) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:246) at android.app.ActivityThread.main (ActivityThread.java:8587) 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)

KojiNakamaru commented 2 years ago

Thank you for the report. I modified Destroy() in #784 to immediately set mWebView to null for making mPlugin.IsInitialized() return false at the following:

https://github.com/gree/unity-webview/blob/b328acb067a3a18ec0318dda58104b8142bbce57/plugins/Android/webview/src/main/java/net/gree/unitywebview/CWebViewPlugin.java#L97-L107

Though I haven't reproduce the issue, this fix should reduce the issue. Could you please try the latest?

josemgmz commented 2 years ago

Hi we try the lastest version and we are still getting this error messages:

00 pc 000000000001f26c /system/lib64/libc.so (syscall+28)

00 pc 00000000000228b4 /system/lib64/libc.so (__futex_wait_ex(void volatile, bool, int, bool, timespec const)+140)

00 pc 0000000000091454 /system/lib64/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t, bool, timespec const)+628)

00 pc 000000000017b93c /data/app/app.kokorokids.app-CRBFMBBKqyDidP6frKgE5g==/lib/arm64/libunity.so (???)

00 pc 000000000017b7f0 /data/app/app.kokorokids.app-CRBFMBBKqyDidP6frKgE5g==/lib/arm64/libunity.so (UnitySendMessage+116)

00 pc 00000000003404e0 /data/app/app.kokorokids.app-CRBFMBBKqyDidP6frKgE5g==/lib/arm64/libunity.so (???)

at com.unity3d.player.UnityPlayer.nativeUnitySendMessage (Native method) at com.unity3d.player.UnityPlayer.UnitySendMessage (unavailable) at net.gree.unitywebview.CWebViewPluginInterface$1.run (CWebViewPluginInterface.java:100) at android.app.Activity.runOnUiThread (Activity.java:6348) at net.gree.unitywebview.CWebViewPluginInterface.call (CWebViewPluginInterface.java:98) at net.gree.unitywebview.CWebViewPlugin$3$2.onReceivedHttpError (CWebViewPlugin.java:436) at Zw.handleMessage (chromium-Monochrome.aab-stable-451511523:83) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:201) at android.app.ActivityThread.main (ActivityThread.java:6864) at java.lang.reflect.Method.invoke (Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)

could it be happening in places other than destroy?

KojiNakamaru commented 2 years ago

Thanks again for the report.

could it be happening in places other than destroy?

For this point, I fixed another part in #792 and #793.This fix however won't help much for the current issue as the stack trace indicates the error occurred for onReceivedHttpError.

Therefore, I replaced UnitySendMessage with MyUnitySendMessage in #794. This custom method utilizes a message queue to pass messages to the unity side and doesn't rely on UnitySendMessage, so it should be free from the issue here. Could you please try the latest?

felipecastrosales commented 2 years ago

@josemgmz did you manage to solve this problem? I have one similar.