Commit Graph

71 Commits

Author SHA1 Message Date
Andres Suarez
79023ee190 Update copyright headers from Facebook to Meta
Reviewed By: bhamodi

Differential Revision: D33331422

fbshipit-source-id: 016e8dcc0c0c7f1fc353a348b54fda0d5e2ddc01
2021-12-27 14:31:45 -08:00
Artem Kholodnyi
72b652fb87 Fix the observer effect in Images Flipper plugin (encoded cache)
Reviewed By: oprisnik

Differential Revision: D31897870

fbshipit-source-id: bdd70d1679029931339ee589c98114f51646cb68
2021-10-25 10:11:48 -07:00
Artem Kholodnyi
11e7bbf9cf Fix the observer effect in Images Flipper plugin
Reviewed By: oprisnik, wizh

Differential Revision: D31379424

fbshipit-source-id: 96040dd0d37442d80a660814bd356571d075aa2c
2021-10-12 09:15:53 -07:00
Omer Strulovich
1db39b8171 Enable and apply Ktfmt to xplat/simplesql, xplat/sonar, and xplat/spectrum
Summary: As title.

Reviewed By: zertosh

Differential Revision: D30425160

fbshipit-source-id: c72d270d7cd3f30990aac55e33e8f72d60ed5fe2
2021-08-19 07:29:30 -07:00
Pascal Hartig
fc73e0d4ec Revert "Improve protobuf support (#2513)" (#2665)
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
2021-08-09 04:15:49 -07:00
Harold Martin
efd75ea435 Improve protobuf support (#2513)
Summary:
* Update protobuf library to support map types
* Improved usage messaging in UI
* Always attempt to decode requests with a protobuf definition
## Changelog
Improved protobuf support

Pull Request resolved: https://github.com/facebook/flipper/pull/2513

Reviewed By: mweststrate

Differential Revision: D30162379

Pulled By: passy

fbshipit-source-id: 201fb06045822641be5840b121da180a201be974
2021-08-09 02:42:35 -07:00
Omar Busto Santos
98f56a30ed Removed bolts-applinks dependency not in use (#2580)
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
2021-07-23 05:26:58 -07:00
Harold Martin
62967314c1 Update Protobuf support (#2381)
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
2021-06-02 12:04:24 -07:00
Pascal Hartig
d1dfc395d1 Revert D28795384: Bump protobuf_java_to_protobufjs from 0.0.1 to 0.1.0
Differential Revision:
D28795384 (09951d505e)

Original commit changeset: 56e791ff245c

fbshipit-source-id: 05c98ff21a789fbd363e707869d5ef7e7b6d6b12
2021-06-01 09:24:57 -07:00
dependabot[bot]
09951d505e Bump protobuf_java_to_protobufjs from 0.0.1 to 0.1.0 (#2391)
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 />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.github.hbmartin:protobuf_java_to_protobufjs&package-manager=gradle&previous-version=0.0.1&new-version=0.1.0)](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
2021-06-01 09:08:44 -07:00
Pascal Hartig
6279cc68b1 Upgrade to Gradle 7 (#2279)
Summary:
Depends on https://github.com/facebook/flipper/issues/2277. Fixes https://github.com/facebook/flipper/issues/2221.

The maven plugin is no longer exposed and implied by https://developer.android.com/studio/build/maven-publish-plugin.

Pull Request resolved: https://github.com/facebook/flipper/pull/2279

Test Plan: ./gradlew uploadArchives -PdryRun=true

Reviewed By: priteshrnandgaonkar

Differential Revision: D28473692

Pulled By: passy

fbshipit-source-id: 3d95122fecebfeac8bfa5173c5c633eee3f13311
2021-05-17 07:29:49 -07:00
Harold Martin
4d262c0da4 Add protobuf support to network inspector (#2080)
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: ![screenshot](https://user-images.githubusercontent.com/745166/111652068-001a5e80-87c4-11eb-8c94-e19b46dd074c.png)

Reviewed By: mweststrate

Differential Revision: D27507451

Pulled By: passy

fbshipit-source-id: 586d891b74f2b17d28fe7a2a99074da755851f38
2021-04-20 05:10:39 -07:00
Harold Martin
b0cbf39a1a Export protobuf definitions from Retrofit (#2084)
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
2021-04-07 13:31:23 -07:00
Pascal Hartig
3d3724ac8b Fix copyright headers
Summary: OSS violation: P242776146

Reviewed By: jknoxville

Differential Revision: D26756475

fbshipit-source-id: bc36fe083101af89f80da293ebafa8a02fd4a052
2021-03-02 12:15:00 -08:00
Harold Martin
4d8be35d1a Add plugin for LeakCanary 2 (#1959)
Summary:
Add plugin for LeakCanary 2 as requested various times: https://github.com/facebook/flipper/issues/1379 https://github.com/facebook/flipper/issues/832  https://github.com/square/leakcanary/issues/1777

## Changelog

* Adds a leakcanary2 plugin for Android
* Adds support for leakcanary2 to existing desktop plugin

Pull Request resolved: https://github.com/facebook/flipper/pull/1959

Test Plan:
* Docs updated to show new implementation
* Should old leakcanary plugin in sample be replaced?

Reviewed By: mweststrate

Differential Revision: D26691637

Pulled By: passy

fbshipit-source-id: 5e236fa6cc124f0720a6b21b5ee7c117ccf96fbf
2021-03-01 09:11:37 -08:00
Pascal Hartig
b25de27b8a Move bolts dependencies to Fresco plugin (#1937)
Summary:
Fixes https://github.com/facebook/flipper/issues/1919

Somehow the diff author put the dependencies in the root `build.gradle`, which is unnecessary as this is only used by Fresco.

Pull Request resolved: https://github.com/facebook/flipper/pull/1937

Test Plan:
Built the sample app, checked that the Fresco stuff continues to work.
![Screenshot_1613565381](https://user-images.githubusercontent.com/9906/108205459-0366ef80-711d-11eb-8b3b-f804f02622af.png)

Reviewed By: mweststrate

Differential Revision: D26483701

Pulled By: passy

fbshipit-source-id: 88f056ed0897f2c00844e02721eb45d5b85c6908
2021-02-18 09:31:04 -08:00
Pascal Hartig
87d7bcf274 Remove JCenter specifics (#1914)
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
2021-02-10 07:16:32 -08:00
bizzguy
f806ee41d7 Network plugin - fix issue with responses with empty body (#1776)
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.

![image](https://user-images.githubusercontent.com/337874/102738969-5edd5280-4311-11eb-9b46-33a57a50e334.png)

Reviewed By: mweststrate

Differential Revision: D25804212

Pulled By: passy

fbshipit-source-id: b31cc87619c604b4df76e05bca5c86554a1cabff
2021-01-07 04:15:18 -08:00
Paco Estevez Garcia
51293406d6 Move Litho Flipper Plugin to Litho
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
2020-10-07 15:44:33 -07:00
Paco Estevez Garcia
7acdfc196f Depend on litho-editor-flipper
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
2020-09-22 11:34:32 -07:00
Paco Estevez Garcia
0d7cac3952 Add Playground link in Yoga layouts
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
2020-09-17 09:44:27 -07:00
Paco Estevez Garcia
a49ceff441 Remove implicit dependency on Androidx
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
2020-09-03 07:42:18 -07:00
Michel Weststrate
2d7c464f3e Increase OkhttpInterceptor default body size
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
2020-09-02 05:13:07 -07:00
Michel Weststrate
2f7a84115c Fix image rendering
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
2020-09-02 05:13:06 -07:00
Paco Estevez Garcia
ff3584e2e0 Add support for tagged messages on the Layout Inspector
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
2020-08-28 08:56:21 -07:00
Paco Estevez Garcia
19b5b65081 Add picker types for Yoga Layout values
Summary: This diff converts several flexbox properties to picker values

Reviewed By: colriot

Differential Revision: D23396217

fbshipit-source-id: 581a609a5e6da85c40d4a20c81f020e1832f2f4c
2020-08-28 07:45:41 -07:00
Paco Estevez Garcia
b109fc4d3e FQN Cleanup
Summary: Fixing a silly missing import

Reviewed By: muraziz

Differential Revision: D23265033

fbshipit-source-id: 0e78d19314df853d2c512535650d3294bf3099e0
2020-08-25 04:28:51 -07:00
Dominik Wielgórski
939ed27aad Detect if given Component is LithoComponent
Summary: Useful for next diffs: enables to detect whether we have LithoComponent or CKComponent

Reviewed By: adityasharat

Differential Revision: D23128972

fbshipit-source-id: b9aef358c1426df4f05213c42e43402e8cae984f
2020-08-17 10:20:53 -07:00
John Knox
9efcbdceaf Send large responses in chunks
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
2020-08-10 08:47:32 -07:00
James Harmon
6989fa608d Add HTTP Status Code to mock response for Route (#1441)
Summary:
Mock requests can currently only return an HTTP Status Code of 200.  This is not sufficient to take full advantage of the mocking feature.  It would be more useful to specify a status code for the response.  Then not only can the original request be tested, but failure of the call could be tested as well.

This is described in Issue https://github.com/facebook/flipper/issues/1423 [https://github.com/facebook/flipper/issues/1423]

Changelog: Allow user to change response code for a mock request

Pull Request resolved: https://github.com/facebook/flipper/pull/1441

Test Plan:
Here is a video demonstrating the change
[Uploading response-status-code.mp4.zip…]

Here is a screenshot showing where the new HTTP status code is entered for the mock request:
![image](https://user-images.githubusercontent.com/337874/89370139-a1c1c500-d6a5-11ea-9a55-e5e99ba37af5.png)

This screenshot shows a mock response with an alternate return code:
![image](https://user-images.githubusercontent.com/337874/89370265-ecdbd800-d6a5-11ea-82e7-10afbd5dd939.png)

Reviewed By: jknoxville

Differential Revision: D22977811

Pulled By: passy

fbshipit-source-id: c1662dd02abeb4546c80a416ed87f8e0dadbf96a
2020-08-07 09:30:10 -07:00
Dominik Wielgórski
3a628019f7 Detect classes which are Litho Sections
Summary:
Populate class name for Litho Sections.
See D22922106 (86cafb9e80) for reference

Reviewed By: adityasharat

Differential Revision: D22949896

fbshipit-source-id: d804971708cf8c8466dd74eda3e750957dc95fc9
2020-08-06 13:11:27 -07:00
Dominik Wielgórski
86cafb9e80 Detect classes which are Litho Components
Summary: Populate class name for Litho Components.

Reviewed By: adityasharat

Differential Revision: D22922106

fbshipit-source-id: e18b748e0e0bd6f511558124a28b4b58d217ded7
2020-08-05 01:49:13 -07:00
Mathias Fleig Mortensen
e466bc4aed Make disk cache inspection toggleable
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
2020-07-27 09:44:52 -07:00
Paco Estevez Garcia
10f9a48540 Wire Editor to Flipper
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
2020-07-27 05:09:16 -07:00
Aziz Murtazaev
b7c34d336a Add ability to modify rotation value of components in Flipper layout inspector plugin
Reviewed By: colriot

Differential Revision: D21526381

fbshipit-source-id: ed692cb9c1bf7d38bef156d2e808b55c76ed3e05
2020-06-02 02:35:41 -07:00
Chaiwat Ekkaewnumchai
f06dc46c06 (client) Change Litho Descriptor
Summary: Similar to previous diff but for Litho component

Reviewed By: mweststrate

Differential Revision: D21040426

fbshipit-source-id: 32e997269bbda472917c8ff6f176d05cf502b9dc
2020-05-07 03:40:59 -07:00
Chaiwat Ekkaewnumchai
168d06011f Try to Retrieve Body from Request
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
2020-04-29 10:47:16 -07:00
Chaiwat Ekkaewnumchai
f3edfb36db Fix Stream Closed IOException
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
2020-04-22 09:28:11 -07:00
Mathias Fleig Mortensen
57c573d973 Add disk cache support for Images plugin
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
2020-03-27 06:32:46 -07:00
John Knox
a30d5f3e60 Don't throw when reporting network request
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
2020-03-25 17:39:20 -07:00
Chaiwat Ekkaewnumchai
79141f5fd2 (Client) Clean up Android FlipperOkHttpInterceptor
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
2020-03-23 22:03:10 -07:00
Qichuan (Sean) ZHANG
d27e45d7bb (Client) Network Response Mocking Logic for Android Clients (Original PR) (#488)
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}

![60549983-187ce800-9d59-11e9-8f7a-4b1b6402653d](https://user-images.githubusercontent.com/410850/61124971-0c242800-a4db-11e9-8e11-8a0a45bbb621.gif)

- 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
2020-03-23 22:03:10 -07:00
Chaiwat Ekkaewnumchai
4ea1497387 (Client) Add isMock to ResponseInfo Object
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
2020-03-23 22:03:09 -07:00
Hilal Alsibai
68bc277c6c Add theme data for components in the layout inspector
Summary: Adds the theme information relating to a Litho component in the layout inspector

Reviewed By: sjkirby

Differential Revision: D20133889

fbshipit-source-id: 93acb745f47c1ff9ce37be35a05b4a6269193a47
2020-02-27 12:36:30 -08:00
Zac Sweers
48d6ea4c30 Remove stetho (#762)
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
2020-01-28 05:24:30 -08:00
Alexander Oprisnik
ad720b1f63 Fix CloseableReference leaks in Flipper plugin
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
2020-01-17 12:32:01 -08:00
Eric O'Connell
b24c2e0b52 Limit request/response body to 100kb to address #457 (#617)
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
2020-01-17 03:55:51 -08:00
Rong Tang
83641ff05c Show Encoded Cache in Flipper Image plugins.
Summary: load encoded cache and pass to flipper to show.

Reviewed By: oprisnik, passy

Differential Revision: D18643671

fbshipit-source-id: 2df34e0f67ccc585834f02760a1e28079bcf4a6f
2019-11-28 04:30:02 -08:00
Mihaela Ogrezeanu
4d324075e9 Show caller stack trace
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
2019-11-19 10:28:18 -08:00
Sara Valderrama
353cfeafc8 update accessibility hierarchy to treat lithoViews and LithoRecyclerViews as ViewGroups
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
2019-11-19 10:04:10 -08:00