Summary:
Protobuf based APIs are becoming more common (i.e. gRPC) but are difficult to inspect. Unlike plain text data formats (JSON), Protobuf calls transmit binary data requiring the format to be known ahead of time, making ad-hoc inspection impossible. This PR allows for those format definitions (messages in protobuf terminology) to be transmitted from the client to the network inspector plugin. These definitions are then imported into ProtobufJS which enables the binary data transmitted to be inspected as easily as JSON data.
See Retrofit PR in https://github.com/facebook/flipper/pull/2084
## Changelog
* Add ProtobufJS library to network plugin
* New `ProtobufFormatter` UI in `RequestDetails`
* `ProtobufDefinitionsRepository` to cache and load protobuf defintions
* `addProtobufDefinitions` call in the Android network plugin
Pull Request resolved: https://github.com/facebook/flipper/pull/2080
Test Plan: 
Reviewed By: mweststrate
Differential Revision: D27507451
Pulled By: passy
fbshipit-source-id: 586d891b74f2b17d28fe7a2a99074da755851f38
Summary:
https://github.com/facebook/flipper/pull/2080 enables storing protobuf definitions and displaying payloads in the network inspector plugin. However, describing those definitions in ProtobufJS format can be time consuming and error prone. This PR enables sending definitions from an entire Retrofit service with a single line.
## Changelog
* Adds a retrofit2-protobuf plugin
Pull Request resolved: https://github.com/facebook/flipper/pull/2084
Test Plan:
Used as a single line per service, ie:
`SendProtobufToFlipperFromRetrofit(baseUrl, PersonService::class.java)`
For more details see demo app in https://github.com/hbmartin/protobuf_java_to_protobufjs
Reviewed By: mweststrate
Differential Revision: D27507872
Pulled By: passy
fbshipit-source-id: 859d7636c9512de0abde0aa1dcb2e023851369cf
Summary:
This removes Bintray/JCenter specific code and replaces it with a new plugin recommended by [Chris Banes](https://chris.banes.dev/publishing-to-maven-central/).
Pull Request resolved: https://github.com/facebook/flipper/pull/1914
Test Plan:
Manually uploaded as snapshot and full release, but with this setup still requires all sorts of manual setup, including GPG. Next PR will include automation for this.
CI here should also verify that I didn't split this diff up incorrectly.
Reviewed By: jknoxville
Differential Revision: D26367350
Pulled By: passy
fbshipit-source-id: faa6b488d6c95bc643d2f9328362e29fb4b05ded
Summary:
The Network Plugin does not properly handle network requests that return an empty body (because of the body actually being empty or because the network call returns something like a 404 status).
Also, the creation of mocks using the "Copy Highlighted" command when the original response returns an empty body is not handled properly.
## Fix
The Android plugin now returns a response when the body length is 0.
The client plugin creates a body containing an empty string instead of null when the body is empty.
## Changelog
Fix problem in Network Plugin when original call or mock has an empty body in the response.
Pull Request resolved: https://github.com/facebook/flipper/pull/1776
Test Plan:
The following screen output for the Network Plugin shows that the call is now being handled correctly. The fields for "status", "size" and "duration" are now populated.
Also, the mock calls are properly defined and shown in yellow.

Reviewed By: mweststrate
Differential Revision: D25804212
Pulled By: passy
fbshipit-source-id: b31cc87619c604b4df76e05bca5c86554a1cabff
Summary:
The current ownership and release model prevents cleanly releasing new versions of the plugin while the code is split between two repos.
This diff moves the flipper-litho plugin to the Litho repository. You'll find new releases as `litho-editor-flipper` that'll be reexported via gradle's `api` to the old artifact.
Reviewed By: colriot
Differential Revision: D23962234
fbshipit-source-id: 7884423342904219ae9b41632c6df90cda870798
Summary: FlipperEditor has migrated to `litho-editor-flipper`, so this diff fixes the dependency tree and deletes the file.
Reviewed By: muraziz
Differential Revision: D23380023
fbshipit-source-id: 75f5f037dc392194212fc156499f090c381999bd
Summary:
Adds a link to the Yoga playground atop all properties of Yoga-based views.
We could make the playground match the properties below if I figure out the hashing mechanism the website uses. This is a start.
Reviewed By: muraziz
Differential Revision: D23758538
fbshipit-source-id: 6a3f206914aa9962e55852df548f8026783506e9
Summary: This change removes the dependency of FlipperEditor from AndroidX, which prevents it from moving to the Litho repository
Reviewed By: Andrey-Mishanin
Differential Revision: D23475867
fbshipit-source-id: a330c676859ed9ce9a0ab186dd206310d2eccca5
Summary:
The default max body size for the OkHttpInterceptor that is reported to Flipper seems unreasonably small, as most images, graphql responses etc are bigger. Increased it to 1MB
Since the network plugin doesn't do any work if it is not explicitly enabled in Flipper, this should not lead to further performance regression / starvation.
Reviewed By: jknoxville
Differential Revision: D23375720
fbshipit-source-id: e901105209aec7108d61fc20295a149c5582f22d
Summary:
Images in the network plugin are rarely displayed in the network plugin, as it tries to use the public url to preview it. However, that won't if the endpoint is behind authentication, idempotent, etc. This diff changes the behavior to instead send the network body to flipper and use that to preview.
Changelog: [Network] Fixed image preview
Reviewed By: jknoxville, passy
Differential Revision: D23370743
fbshipit-source-id: 0070e9e38c10a5761b9f7190467e26f01a7b2471
Summary:
Related diff [CK]: D23243009
This diff adds support for a protocol for layout messages where the type is recursively encoded as:
```
{
kind: "type",
data: ???
}
```
The meat of the diff is on FlipperEditor.java, SetDataOperations.java and InspectorFlipperPlugin.java. The others are there just for a change on an interface.
We check if the message adheres to the new encoding, otherwise we fall back to the old behavior. If it's the new encoding, the message is traversed recursively flattening the types to EditorValue using the type hints provided.
Reviewed By: muraziz
Differential Revision: D23243009
fbshipit-source-id: 0f313455885930f3beaaadb66f3bf394f109ea23
Summary: Useful for next diffs: enables to detect whether we have LithoComponent or CKComponent
Reviewed By: adityasharat
Differential Revision: D23128972
fbshipit-source-id: b9aef358c1426df4f05213c42e43402e8cae984f
Summary:
It's common for responses to be completely missing in the network inspector. This is because they are larger than can be serialized in one go on some devices, so we drop all messages larger than 1MB.
This changes the android client to send large responses in individually serialized batches. This way we avoid running out of memory and can still send arbitrarily large payloads.
Changelog: Android network inspector can now handle responses large than 1MB.
Reviewed By: passy
Differential Revision: D22999905
fbshipit-source-id: ff4eb8fa72a7e42ea90d12ffe0f20c6d1e58b7e5
Summary:
Populate class name for Litho Sections.
See D22922106 (86cafb9e80) for reference
Reviewed By: adityasharat
Differential Revision: D22949896
fbshipit-source-id: d804971708cf8c8466dd74eda3e750957dc95fc9
Summary: Populate class name for Litho Components.
Reviewed By: adityasharat
Differential Revision: D22922106
fbshipit-source-id: e18b748e0e0bd6f511558124a28b4b58d217ded7
Summary: Adds a toggle switch to show/hide disk cache images defaulting to inactive. The image data is only sent on the adb connection when the toggle is activated.
Reviewed By: defHLT
Differential Revision: D20002059
fbshipit-source-id: 05c9e515ffe09441e5cfb6f66eb14559ac4a322c
Summary:
This diff implements the integration between a Litho Editor and Flipper. It does so by converting the Editor format to FlipperObject, and then converting it back from FlipperDynamic.
This conversion works for both `State` and `Prop`. We already provide default implementations for primitive + wrapped types and String, so the functionality should match the existing one.
Reviewed By: passy, Katalune
Differential Revision: D22455220
fbshipit-source-id: f7f633765f3d997ce6de09d2c1277019e72c0802
Summary: Similar to previous diff but for Litho component
Reviewed By: mweststrate
Differential Revision: D21040426
fbshipit-source-id: 32e997269bbda472917c8ff6f176d05cf502b9dc
Summary:
Previously, requests were passed to process first in an interceptor, and it is responsibility of an interceptor to process requests for responses. In FlipperOkhttpInterceptor, we did read data from request body before processing it. This caused a bug when the network process itself wants to also read that data, but the stream has been closed because the interceptor has just read. The fix is to report request body after we have triggered network call so that we can just drop request body if we cannot read.
This diff tries to bring back the same functionality while not cause the bug to occur by cloning the content to be read by Flipper and using the same one for the request.
Reviewed By: jknoxville
Differential Revision: D21279679
fbshipit-source-id: 47f8b29a1896705d8d2d601661cd485db572d251
Summary:
Original Issue: https://github.com/facebook/flipper/issues/993
The exception occurs when OkHttp and we try to read request body twice, while it can be only read once.
Hence, we will read request body after it is processed by OkHttp.
Tradeoff for this is requests on Flipper will not appear immediately after fired, but they will appear together with their responses.
There are ways we can get rid of the tradeoff. For example, as demonstrated in D21167308, OkHttp ^3.14.0 contains method `isOneShot`, which can be used to check if we can read request body more than once. Another example is to change server side to accept nullable variable so that we can send request body and others separately.
Reviewed By: passy
Differential Revision: D21175341
fbshipit-source-id: 053789a2c2f28cd8149ea1bb36fd0cfe1c668df7
Summary:
Tracks images in disk cache. It seems performant even with 500+ images in disk cache. Sidebar displays the local path for an image when that image is selected. Shows total size of images in disk cache. 'Clear Cache' clears the disk cache.
For now we unpack the async cache request in the plugin, should implement a `getSync()` method on `bufferedDiskCache` in the future. For some reason Flipper doesn't work with a blocking call (https://fburl.com/smj0s4li).
Reviewed By: defHLT
Differential Revision: D20001062
fbshipit-source-id: 1e7a7900e9f42d05e3bf30472e57cd643caa5aca
Summary: Flipper should never crash the mobile app. This is a plugin entry point, so it's understandable that it can, but we should avoid it whenever possible.
Reviewed By: passy
Differential Revision: D20648373
fbshipit-source-id: f32b428cccdd0c78eb15e9e95a64ecf3f4e10429
Summary:
This is the change made by Pascal at D19813495. to clean up the file
Shouldn't really change how it works but makes it
safer and brings it in line with our coding standards.
Reviewed By: passy
Differential Revision: D20474258
fbshipit-source-id: 67d77316a5b7efd7258072b4f35a2d9c50de408e
Summary:
Add logic on client side
# How it works (from the code)
1. Server side sends request url and method to response data and headers to client side
1.1. This will happen every time server update **any** mock response (add, edit, and remove)
2. Client stores those in map
3. For every network request,
3.1. Check if there is a matching url and method
3.2. If so, create a new response with the data and headers and drop the request
3.3. If not, proceed and send the request and wait for a response
`addNetworkInterceptor` is changed to `addInterceptor` to allow short-circuit and proceed without fetching anything. More info can be found at https://square.github.io/okhttp/interceptors/
Note:
- This is an original PR.
- The content below is from original PR
Add network response mocking for Network plugin. See discussion [here](https://github.com/facebook/flipper/issues/475)
## Changelog
- Add Network response mocking, currently support Android clients only
- Change the Android example app to use `addInterceptor()` instead of `addNetworkInterceptor()`
Pull Request resolved: https://github.com/facebook/flipper/pull/488
Test Plan:
{F231673798}

- Connect an Android device
- Tap on Network plugin
- Click on the Mock button
- Click on Add Route button, and specify the URL
- Edit the mock data in the text area
- Optionally, click the Headers tab to edit the headers data
- Click close button to close the dialog
- Send some network data in your application. You should be able to see the mock data appears in the Network table in those rows highlighted in yellow
Reviewed By: passy
Differential Revision: D16580291
Pulled By: cekkaewnumchai
fbshipit-source-id: fc391f5e7efebc6f51a72b00d16263e009e1fdb0
Summary:
per title
Note:
- This is a part of this PR: https://github.com/facebook/flipper/pull/488
Reviewed By: jknoxville
Differential Revision: D20474257
fbshipit-source-id: d2ac79d03ac67453bd67ecc46ace973be1590c04
Summary: Adds the theme information relating to a Litho component in the layout inspector
Reviewed By: sjkirby
Differential Revision: D20133889
fbshipit-source-id: 93acb745f47c1ff9ce37be35a05b4a6269193a47
Summary:
## Summary
Resolves https://github.com/facebook/flipper/issues/607
This removes stetho dependencies directly in favor of just copying in the used classes. This removes the last non-androidx dependency from the project, and is useful as stetho appears to be unmaintained. The fresco stetho dependency appeared to be completely unused.
## Changelog
Remove stetho dependencies. It was unused other than a few utility methods, but came at the cost of preventing Flipper consumers from completely removing dependencies that hadn't updated to Androidx yet.
Pull Request resolved: https://github.com/facebook/flipper/pull/762
Test Plan: Existing tests still pass with no regressions. Functionally this should be no difference.
Reviewed By: jknoxville
Differential Revision: D19577969
Pulled By: passy
fbshipit-source-id: b277ddf97a9d2c846dd0b9227c02bb46c1ecd930
Summary:
When debugging closeable reference leaks, I found that the Flipper plugin doesn't properly close one:
```
2020-01-17 10:45:29.346 27038-27053/com.facebook.wakizashi D/YOLO: LEAK!!:
java.lang.Throwable
at com.facebook.common.references.CloseableReference.<init>(CloseableReference.java:158)
at com.facebook.common.references.DefaultCloseableReference.<init>(DefaultCloseableReference.java:29)
at com.facebook.common.references.CloseableReference.of(CloseableReference.java:237)
at com.facebook.common.references.CloseableReference.of(CloseableReference.java:203)
at com.facebook.common.references.CloseableReference.of(CloseableReference.java:176)
at com.facebook.imagepipeline.cache.CountingMemoryCache.newClientReference(CountingMemoryCache.java:221)
at com.facebook.imagepipeline.cache.CountingMemoryCache.get(CountingMemoryCache.java:209)
at com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin$4.onReceive(FrescoFlipperPlugin.java:204)
at com.facebook.flipper.android.EventBase.loopForever(Native Method)
at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:31)
```
Second leak:
```
2020-01-17 11:04:16.503 28855-28869/com.facebook.wakizashi D/YOLO: LEAK!!:
java.lang.Throwable
at com.facebook.common.references.CloseableReference.<init>(CloseableReference.java:147)
at com.facebook.common.references.DefaultCloseableReference.<init>(DefaultCloseableReference.java:21)
at com.facebook.common.references.DefaultCloseableReference.clone(DefaultCloseableReference.java:35)
at com.facebook.common.references.CloseableReference.cloneOrNull(CloseableReference.java:258)
at com.facebook.common.references.CloseableReference.cloneOrNull(CloseableReference.java:326)
at com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfoEntry.<init>(CountingMemoryCacheInspector.java:32)
at com.facebook.imagepipeline.cache.CountingMemoryCacheInspector.dumpCacheContent(CountingMemoryCacheInspector.java:101)
at com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin$3.onReceive(FrescoFlipperPlugin.java:171)
at com.facebook.flipper.android.EventBase.loopForever(Native Method)
at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:31)
```
Reviewed By: passy
Differential Revision: D19445902
fbshipit-source-id: 12a513d9e34fcac0d546a4eac55932956e4e4d5b
Summary:
As previously reported in https://github.com/facebook/flipper/issues/457, I immediately started to see crashes with Flipper integrated due to large responses (e.g., >= 100MB). This will only write the first 100KB of the response or request body into `RequestInfo` objects.
## Changelog
- Limits request/response body in network request info to 100KB max.
Pull Request resolved: https://github.com/facebook/flipper/pull/617
Test Plan:
- Make a network request which has a response size of < 100kb, verify that it is visible in its entirety
- Make a network request w/ response size > 100kb, verify that it is truncated
- Ideally, use your application with the Network plugin running, and do not see OOMs
Reviewed By: mweststrate
Differential Revision: D19412075
Pulled By: passy
fbshipit-source-id: c93662dba7a5f24820287e56e889576b5bcb5a72
Summary: On Android, the stack trace looks different so we don't need to use the Regex we use on iOS. We can simply display all the lines in the trace.
Reviewed By: pasqualeanatriello
Differential Revision: D17181400
fbshipit-source-id: e471da17b89806a161edc7edcf05ac6faed44bf0
Summary: This will correctly show all view children instead of reverting to the non-ax default behavior. Fixes bug where recycler views showed no children.
Reviewed By: jknoxville
Differential Revision: D18574220
fbshipit-source-id: f22606fb582e0bfd1a171dc4497e1d1613e800d1
Summary:
Base64 encoding can easily cause OOMs for large payloads.
In the long-term, it would be great to have a way of streaming these
responses so we don't allocate 50MB chunks of memory at once.
Reviewed By: jknoxville
Differential Revision: D17951353
fbshipit-source-id: a5d7b8242892518590ac95c1d9751f24d20dc40e
Summary:
I missed these. :(
Open source CI is unhappy about this - for good reasons.
Reviewed By: jknoxville
Differential Revision: D17500071
fbshipit-source-id: 96106f660dee59985c51e2635321ab4ad00a795a
Summary:
Setting up the necessary metadata to publish the separate plugins
to Maven/Bintray.
Reviewed By: danielbuechele
Differential Revision: D17480263
fbshipit-source-id: 1772cee5b3744ce52fc6e2510a27cb7f500e72bf
Summary:
Breaking Litho/Sections off. Doesn't really make sense to have
two deps for this especially since they're pretty tightly coupled.
This makes our core already quite slim.
Reviewed By: jknoxville
Differential Revision: D17420118
fbshipit-source-id: 9a03911f4af6410745b9aefd0e6a75bdf106660f
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/548
First project to pull out of the "fat distribution" we currently have.
Still needs setup for Maven and registration in Bintray.
Reviewed By: jknoxville
Differential Revision: D17395660
fbshipit-source-id: 6244495a2e25d705dd930ef87c7e5e1f038eb921
Summary:
This is a big one. Moves all oss plugins to a new place and leaves
stub targets in place. No logic changes. Everything apart from
BUCK files should be unchanged.
Reviewed By: jknoxville
Differential Revision: D8951045
fbshipit-source-id: 8054fb4028181d5cc4a240b1908dab6471cf0a27