We want to custom our own ExecutorSupplier
in Fresco for profiling purposes. We call FrescoModule.getDefaultConfigBuilder(reactContext)
first to get default config builder and set ExecutorSupplier on the builder.
Since FrescoModule.getDefaultConfigBuilder(reactContext)
need us to provide ReactContext
, so we call it after we are notified inside ReactInstanceEventListener
. Then we invoke Fresco.initialize(application, imagePipelineConfig)
to initialize it.
But we found a race condition between the Fresco initialization within ReactNative and Fresco we tried to initialize by Fresco.initialize(). Fresco initialization within ReactNative happens on a thread, Fresco.initialize() happens on main thread. Their order are not guaranteed. So our custom configuration is not always applied.
reactInstanceManager.addReactInstanceEventListener(reactContext -> {
...
ImagePipelineConfig imagePipelineConfig =
FrescoModule.getDefaultConfigBuilder(reactContext)
.setExecutorSupplier(new CustomFrescoExecutorSupplier())
.build();
Fresco.initialize(application, imagePipelineConfig);
...
});
Can you help on what should be the right way to set custom configuration based on the default config builder?