In our game application for Android which is based on the game engine cocos2d-x, with most of the code being written in C++, we have a very strange and critical issue since Android 11:
When the native library gets loaded in onLoadNativeLibraries
it now suddenly takes 60+ seconds. Before Android 11, it all worked fine and it loaded in 0.2-3 seconds. Now when you start the game, you have a 60+ seconds gray screen.
We already figured out that JNI_OnLoad
gets called directly after the 60 second stall is over.
Here's the code of the onLoadNativeLibraries
function:
protected void onLoadNativeLibraries()
{
try
{
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String libName = bundle.getString("android.app.lib_name");
System.loadLibrary(libName); // line of 60 seconds stall
}
catch (Exception e)
{
e.printStackTrace();
}
}
We already tried time profiling, but without any success. It just hows that it's spending a lot of time on that function. Also pausing via the debugging doesn't lead to any further clues. The native debugger doesn't show anything on the C++ side of the code.
Does anybody have any idea why this is happening or what we could try to figure it out? Any help would be highly appreciated :)
android:extractNativeLibs
in your manifest? Which Android Gradle Plugin version do you build with? Is the load time the same in release mode as in debug mode? – Respirablebuild.gradle
file. It ought to have a version starting with 3 or 4. – Respirableclasspath 'com.android.tools.build:gradle:3.6.1'
Yes, it happes always. 100% of the time. – Disciplinant