From 9e13b90708c47c85627961b22a75d0122f4d5f86 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Thu, 20 Jun 2019 03:46:26 -0700 Subject: [PATCH] Add setup docs for Fresco/Images Summary: Per title. Reviewed By: danielbuechele Differential Revision: D15898614 fbshipit-source-id: b2d86a58e80b1309159bc738bcc66ca09cd796ad --- docs/features/images-plugin.md | 2 ++ docs/setup/images-plugin.md | 64 ++++++++++++++++++++++++++++++++++ website/i18n/en.json | 4 +++ website/sidebars.json | 1 + 4 files changed, 71 insertions(+) create mode 100644 docs/setup/images-plugin.md diff --git a/docs/features/images-plugin.md b/docs/features/images-plugin.md index 4045b48b5..bb4563808 100644 --- a/docs/features/images-plugin.md +++ b/docs/features/images-plugin.md @@ -3,6 +3,8 @@ id: images-plugin title: Images --- +→ [See setup instructions for the images plugin](setup/images-plugin.md) + The images plugin allows you to inspect what images were fetched, where they are coming from and selectively clear caches. Currently, the plugin supports [Fresco](https://github.com/facebook/fresco/) as backend. diff --git a/docs/setup/images-plugin.md b/docs/setup/images-plugin.md new file mode 100644 index 000000000..e31c077c9 --- /dev/null +++ b/docs/setup/images-plugin.md @@ -0,0 +1,64 @@ +--- +id: images-plugin +title: Images Setup +sidebar_label: Images +--- + +Currently, the images plugin only supports [Fresco](https://frescolib.org/) for Android as backend, but just like the network plugin, support for other image loading libraries +could easily be added. Send us a PR! + +## Fresco and Android + +```java +import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; + +client.addPlugin(new FrescoFlipperPlugin()); +``` + +The `FrescoFlipperPlugin` constructor offers a whole lot of configuration options which +can be useful if you have an advanced setup of Fresco in your application: + + +```java +FrescoFlipperPlugin( + DebugImageTracker imageTracker, + PlatformBitmapFactory bitmapFactory, + @Nullable FlipperObjectHelper flipperObjectHelper, + DebugMemoryManager memoryManager, + FlipperPerfLogger perfLogger, + @Nullable FrescoFlipperDebugPrefHelper debugPrefHelper, + @Nullable CloseableReferenceLeakTracker closeableReferenceLeakTracker) { ... } +``` + +### Leak Tracking + +The Flipper plugin can help you track down `CloseableReferences` who have not had +`close()` called on them. This can have a negative impact on the performance of +your application. + +Do enable this functionality, you need to create a `CloseableReferenceLeakTracker` +and set it in both your `ImagePipelineConfig` for Fresco and the `FrescoPluginPlugin` +on creation. + +```java +import com.facebook.imagepipeline.debug.FlipperCloseableReferenceLeakTracker; + +// ... + +FlipperCloseableReferenceLeakTracker leakTracker = new FlipperCloseableReferenceLeakTracker(); + +new ImagePipelineConfig.Builder() + // ... + .setCloseableReferenceLeakTracker(leakTracker) + .build(); + + +client.addPlugin(new FrescoFlipperPlugin( + new FlipperImageTracker(), + Fresco.getImagePipelineFactory().getPlatformBitmapFactory(), + null, + new NoOpDebugMemoryManager(), + new NoOpFlipperPerfLogger(), + null, + leakTracker)); +``` \ No newline at end of file diff --git a/website/i18n/en.json b/website/i18n/en.json index e77fe1411..bd9d720bd 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -104,6 +104,10 @@ "title": "Databases Plugin Setup", "sidebar_label": "Databases" }, + "setup/images-plugin": { + "title": "Images Setup", + "sidebar_label": "Images" + }, "setup/layout-plugin": { "title": "Layout Inspector Setup", "sidebar_label": "Layout Inspector" diff --git a/website/sidebars.json b/website/sidebars.json index 1f384db25..a2865db0b 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -23,6 +23,7 @@ "setup/layout-plugin", "setup/network-plugin", "setup/databases-plugin", + "setup/images-plugin", "setup/sandbox-plugin", "setup/shared-preferences-plugin", "setup/leak-canary-plugin",