axmol
axmol copied to clipboard
[Android] WebView shouldOverrideUrlLoading ANR
- adxe version: 1.0.0b6
- devices test on: Google Pixel 4a Android 12
- developing environments
- NDK version: 24.0.8215888
- Android Studio version: 2021.1.1 Patch 3
- cmake version: 3.23.2
Steps to Reproduce:
- Create a WebView, load a php file which run JS to refresh every 10s.
- Show a Rewarded Ads (Fluct / Maio SDK), wait the php refresh, then an ANR will occur.
D/Cocos2dxWebViewHelper: https://domain.com/test_refresh.php
D/CocosApp: com.github.anrwatchdog.ANRError: Application Not Responding for at least 5000 ms.
W/System.err: com.github.anrwatchdog.ANRError: Application Not Responding for at least 5000 ms.
W/System.err: Caused by: com.github.anrwatchdog.ANRError$$$_Thread: main (state = WAITING)
W/System.err: at sun.misc.Unsafe.park(Native Method)
W/System.err: at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
W/System.err: at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:868)
W/System.err: at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1023)
W/System.err: at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
W/System.err: at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
W/System.err: at org.cocos2dx.lib.Cocos2dxWebView$Cocos2dxWebViewClient.shouldOverrideUrlLoading(Cocos2dxWebView.java:133)
If change Cocos2dxHelper.runOnGLThread to activity.runOnUiThread in Cocos2dxWebView.java L129, then the ANR will not occur.
It seems the ads make cocos losing the main thread then the CountDownLatch waiting caused an ANR.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.