in drawee-backends/drawee-pipeline/src/main/java/com/facebook/drawee/backends/pipeline/Fresco.java [58:114]
public static void initialize(
Context context,
@Nullable ImagePipelineConfig imagePipelineConfig,
@Nullable DraweeConfig draweeConfig,
boolean useNativeCode) {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.beginSection("Fresco#initialize");
}
if (sIsInitialized) {
FLog.w(
TAG,
"Fresco has already been initialized! `Fresco.initialize(...)` should only be called "
+ "1 single time to avoid memory leaks!");
} else {
sIsInitialized = true;
}
NativeCodeSetup.setUseNativeCode(useNativeCode);
if (!NativeLoader.isInitialized()) {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.beginSection("Fresco.initialize->SoLoader.init");
}
try {
Class<?> clazz =
Class.forName("com.facebook.imagepipeline.nativecode.NativeCodeInitializer");
clazz.getMethod("init", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
// Failed to initialize SoLoader
NativeLoader.initIfUninitialized(new SystemDelegate());
} catch (IllegalAccessException e) {
// Failed to initialize SoLoader
NativeLoader.initIfUninitialized(new SystemDelegate());
} catch (InvocationTargetException e) {
// Failed to initialize SoLoader
NativeLoader.initIfUninitialized(new SystemDelegate());
} catch (NoSuchMethodException e) {
// Failed to initialize SoLoader
NativeLoader.initIfUninitialized(new SystemDelegate());
} finally {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.endSection();
}
}
}
// we should always use the application context to avoid memory leaks
context = context.getApplicationContext();
if (imagePipelineConfig == null) {
ImagePipelineFactory.initialize(context);
} else {
ImagePipelineFactory.initialize(imagePipelineConfig);
}
initializeDrawee(context, draweeConfig);
if (FrescoSystrace.isTracing()) {
FrescoSystrace.endSection();
}
}