Summary:
Apps usually communicate with multiple hosts to support pops and data centres. The problem currently is that for each host we need a different config in the mock tab in flipper. If the host change due to failover then the mocking stops working. Added support to enter the URL without a host in the flipper. We then check if the Url from the actual network request contains the mock URL without a host.
We can change the hint on flipper UI to suggest either entering the complete URL or without the host to allow matching across multiple hosts.
Resolve:[3751](https://github.com/facebook/flipper/issues/3751)
Let me know if the approach looks good.
## Changelog
Pull Request resolved: https://github.com/facebook/flipper/pull/3762
Reviewed By: lblasa
Differential Revision: D36780307
Pulled By: passy
fbshipit-source-id: 744898fa24d13343132e9a2165750241861245bd
Summary:
We shouldn't report an error when Flipper is querying data before Fresco is initialized.
This will be especially useful when we move to lazy Fresco initialization later this year.
Reviewed By: passy
Differential Revision: D33978177
fbshipit-source-id: dfb6cb1b73737adbb557ecb141b043d088b5a574
Summary:
This reverts commit efd75ea435.
Sorry hbmartin! We're running into Kotlin compatibility problems. Your latest library release isn't compatible with Kotlin 1.3 and we can't upgrade just yet because Litho hasn't been able to release in a while. :(
Pull Request resolved: https://github.com/facebook/flipper/pull/2665
Test Plan: _eyes
Differential Revision: D30189360
Pulled By: passy
fbshipit-source-id: c1edbbc496742938579f4e2032a78debe08fcc26
Summary:
As explained in this [Issue](https://github.com/facebook/flipper/issues/1919) when running checks to see if Jetifier is needed to compile any given app using Flipper, it complain due to the dependency on `com.parse.bolts:bolts-applinks:1.4.0`.
```
Scanning com.parse.bolts:bolts-applinks:1.4.0
Absoulute path: /....../bolts-applinks-1.4.0.jar
Graphs to this dependency:
+---com.facebook.flipper:flipper:0.74.0
+---com.parse.bolts:bolts-applinks:1.4.0
> Task :canISayByeByeJetifier FAILED
```
Bolts has already fixed the AndroidX migration in version `1.5.0` but it has never been published ([Issue](https://github.com/BoltsFramework/Bolts-Android/issues/157))
After checking the code i realized flipper is only using `bolts-tasks` in `FrescoFlipperPlugin` ([code](7bd4f80c25/android/plugins/fresco/src/main/java/com/facebook/flipper/plugins/fresco/FrescoFlipperPlugin.java (L14))).
`bolts-applinks` depends on `bolts-tasks` but **not the other way around**, so we can safely remove this dependency.
## Changelog
- Removed dependency on bolts-applinks not in use
Pull Request resolved: https://github.com/facebook/flipper/pull/2580
Test Plan:
### Tests
- [ ] Run unit tests `./gradlew :android:test` and make sure they pass
### Smoke test `fresco-plugin`
- [ ] Make sure `android/sample` compiles and runs
- In the Flipper desktop app enable `Images` plugin
- In the Android sample app tap on `Load Fresco Image`
- [ ] Verify in desktop app that the image shows correctly and the plugin works
Reviewed By: muraziz
Differential Revision: D29849669
Pulled By: jknoxville
fbshipit-source-id: 0cec730de3b94272985fec4a432ca244822f336f
Summary:
**Update protobuf library with new support for `enum` and `oneof` types**
## Changelog
- Update plugin code for library API changes and other cleanup
- Add instructions to readme
Pull Request resolved: https://github.com/facebook/flipper/pull/2381
Test Plan: see demo app at https://github.com/hbmartin/protobuf_java_to_protobufjs
Reviewed By: priteshrnandgaonkar
Differential Revision: D28831035
Pulled By: passy
fbshipit-source-id: 46e196293330b615394606bd3486ea47ad6a0630
Summary:
Bumps [protobuf_java_to_protobufjs](https://github.com/hbmartin/protobuf_java_to_protobufjs) from 0.0.1 to 0.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/hbmartin/protobuf_java_to_protobufjs/releases">protobuf_java_to_protobufjs's releases</a>.</em></p>
<blockquote>
<h2>v0.1.0</h2>
<ul>
<li>Added support for <code>oneof</code></li>
<li>Added support for enums</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/hbmartin/protobuf_java_to_protobufjs/commits/v0.1.0">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
Pull Request resolved: https://github.com/facebook/flipper/pull/2391
Reviewed By: nikoant
Differential Revision: D28795384
Pulled By: passy
fbshipit-source-id: 56e791ff245cdc096e9ef11eb2b436e42e611659
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