cronet-transport-for-okhttp icon indicating copy to clipboard operation
cronet-transport-for-okhttp copied to clipboard

ANRs when loading Cronet Provider

Open adityameesho opened this issue 1 year ago • 1 comments

Sharing some of the ANRs encountered when calling CronetProviderInstaller and when calling build method of CronetEngine.Builder and CronetInterceptor

There is one ANR happening due to System.loadLibrary being called on main thread by Play Services.

Is it safe to call the CronetProviderInstaller.installProvider() on a background thread?

anr_load_library.txt anr1.txt anr2.txt anr3.txt

adityameesho avatar Aug 16 '23 09:08 adityameesho

Hi @adityameesho,

Initializing Cronet can be fairly expensive as it involves loading a non-trivial amount of Java code as well as the native library (which requires its own initialization as well). For this reason, it might indeed be a good idea to do it in a background thread to avoid blocking the UI on the loading process, which could potentially result in ANRs especially if the device is slow or starved of resources (e.g. during app startup).

edechamps-Google avatar Aug 18 '23 14:08 edechamps-Google