Commit Graph

699 Commits

Author SHA1 Message Date
Lorenzo Blasa
bba1275377 Traversal tidy up
Summary: This change tidies up the traversal and removes unused LayoutVisitor

Reviewed By: LukeDefeo

Differential Revision: D39575241

fbshipit-source-id: 2ab101f74ae7b2c16ddf7016abc78a03590916b0
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
1fac19facc Address a few warnings and suggestions for Android sample app
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39575170

fbshipit-source-id: 8be293fe31521531e634132e4ca454da32aad73f
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
84dc95b27b Rename stetho package to util
Summary:
^

These are the last two types imported from stetho which, if anything, can be integrated as is without having to track back to Stetho

Reviewed By: LukeDefeo

Differential Revision: D39573639

fbshipit-source-id: 8009532116ec7b2fed2751fa966269ad81a7cb00
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
d8e47efb81 Remove warnings
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39573417

fbshipit-source-id: 241ecdddaf43020923046b0b5c35656bc8ffad34
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
3a4286b2ba Remove stetho unused types
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39572018

fbshipit-source-id: 437b245b7eee06392cda97eb56b4f4d0a5df23fc
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
86364cbd40 Addresses fragments tracking and different bugs/warnings
Summary:
^

After this change lands, it is safe to remove most of the Stetho fragment support types.

Reviewed By: LukeDefeo

Differential Revision: D39460121

fbshipit-source-id: 0e7d4ce71e828ee7bc9c6e945b8fe27dbd6f08f8
2022-09-20 05:15:50 -07:00
Luke De Feo
2090120cda Descriptor clean up
Summary:
1. The base class descriptor was removed, this was given that we have chained descriptor there is no need for this anymore
2. The Base interface node descriptor no longer has a mutable list based api. You simply return a list. The mutable list based api was specifically to allow chaining and this quirk is isoltated to the chained descriptor
3. AbstractChainedDescriptor and ChainedDescriptor were merged

Reviewed By: lblasa

Differential Revision: D39496073

fbshipit-source-id: fb3ec629ec3b27f587bdbd0b323624a4bc4ebea3
2022-09-14 05:07:51 -07:00
Luke De Feo
f5a5e1b19d Split Tree Observer into multiple files
Summary: Tree observer had multiple components, now their usage is clearer they are moved to separate files

Reviewed By: lblasa

Differential Revision: D39469078

fbshipit-source-id: 4d4c03aff229fd2cc0eace216144b37694637691
2022-09-13 11:05:42 -07:00
Luke De Feo
868ae9e36a Added dialogs to sample app
Summary: This is to allow us to test dialogs from the UI debugger

Reviewed By: lblasa

Differential Revision: D39468653

fbshipit-source-id: 59c759a794c42b85bc288d60e1b2c6a71e32bb3d
2022-09-13 11:05:42 -07:00
Luke De Feo
721b9cd4da Fix logging
Summary: typing uidebugger into ADB will hit both the log tag and any thing else such as package name. Turned Enum warning down to verbose reduce load on main thread

Reviewed By: lblasa

Differential Revision: D39466932

fbshipit-source-id: 0106a042a92755cf644c0e66683e7e5993e924e1
2022-09-13 11:05:42 -07:00
Luke De Feo
f06f63306e Restore root view tracking
Summary: We use the root view resolver to detect when roots have been added. We currently have some race conditions where the activity stack managed by application ref doesnt include the first activity

Reviewed By: lblasa

Differential Revision: D39466929

fbshipit-source-id: fff4f830dea337d96dd9a9956a20a080fff2e965
2022-09-13 11:05:42 -07:00
Luke De Feo
4341cbdf3d Factor out common traversal code in observers
Summary: Each observer was doing a similar job of traversing, and setting up child observers and its easy to not clean up child observers in some cases. This provides a helper utility for the common use case

Reviewed By: lblasa

Differential Revision: D39466930

fbshipit-source-id: e74ae5c3709297b73c020cd148a0485ac9fc0f8f
2022-09-13 11:05:42 -07:00
Luke De Feo
a0ee774159 Fix active child
Summary: The active child was only being passed for the native scan full traversal, Now we have it for the partial traversal also

Reviewed By: lblasa

Differential Revision: D39466933

fbshipit-source-id: a0e281e4f9a21bf2edd12f18ecdb68a29ead3476
2022-09-13 11:05:42 -07:00
Luke De Feo
0562178739 Basic Litho support
Summary: Added an initial litho Tree observer and descriptors, its quiet naive and will be improved in a future diff

Reviewed By: lblasa

Differential Revision: D39466931

fbshipit-source-id: 66a462882af2e585b9719ee2f61595449f99c5e5
2022-09-13 11:05:42 -07:00
Luke De Feo
24ec43eb92 Add observer type to Perf event
Summary: While looking at the event stream it is useful to know which observer type fired it

Reviewed By: lblasa

Differential Revision: D39430756

fbshipit-source-id: bc52f085a5497692f8076b12a9c015cc33a19d1e
2022-09-13 11:05:42 -07:00
Lorenzo Blasa
d999f68f62 Remove warnings
Summary: Addresses a few warnings raised

Reviewed By: LukeDefeo

Differential Revision: D39430004

fbshipit-source-id: 877698e8515f08a5cb38b414689615c1b6e4b6cc
2022-09-12 08:17:39 -07:00
Lorenzo Blasa
ed40e16ac9 Addresses a few issues with the Stetho fragment utilities
Summary:
There is a bug in the code to get fragments from the activity.

A boolean, result from the comparison, was added to the list instead of the actual fragments.

Reviewed By: LukeDefeo

Differential Revision: D39348019

fbshipit-source-id: 669f304055f15f59b40352d86f25d768d92df76e
2022-09-12 04:20:01 -07:00
Luke De Feo
4436128d07 Descriptor clean up
Summary:
Now that we have the tree observer we can make descriptors completely about describing an object. To that end we have removed init method and made them all object to indicate to future readers their singleton nature.

onGetActive child was made open instead of abstract to avoid needed to override in all subclasses

Reviewed By: lblasa

Differential Revision: D39387935

fbshipit-source-id: 802b8afdd9aa639daecf10d774ca5b960ee48003
2022-09-12 03:48:43 -07:00
Luke De Feo
9a270cdc7a Tree observer
Summary:
Added concept of a tree observer which is responsible for listening to the changes for a portion of the UI tree. This structure nests so Tree observers can hold child tree observers which emit events on a different cadence. This structure should allow us to incorporate different UI frameworks down the road as well as native android views.

We push the tree updates from the tree observers onto a channel and setup a coroutine to consume this channel, serialize and send down the wire.

Reviewed By: lblasa

Differential Revision: D39276681

fbshipit-source-id: a4bc23b3578a8a10b57dd11fe88b273e1ce09ad8
2022-09-12 03:48:43 -07:00
Luke De Feo
c76c993ce4 Introduced concept of active child
Summary: A node can have an active child, if present we assume all others are inactive and we don't traverse them. This means the activities not on top and view pager views not active will not be scanned. Additionally on the desktop we are automatically collapsing these views. The net result is a lot less work done on the main thread

Reviewed By: lblasa

Differential Revision: D39310126

fbshipit-source-id: ebd0c69d46f2d42fe42e678c8327fcdc73d08385
2022-09-12 03:48:43 -07:00
Lorenzo Blasa
6fcaaabb17 Remove unused observer
Summary:
^

This was replaced by `ApplicationRef`

Reviewed By: antonk52

Differential Revision: D39313539

fbshipit-source-id: ad9b5c3ed963046ba0349fd5112bb9cb5de7640b
2022-09-08 04:26:41 -07:00
Luke De Feo
2fc1ff9f9c Added increment activity
Summary: Added simple activity to test how flipper reacts to changes in native UI

Reviewed By: passy

Differential Revision: D38704012

fbshipit-source-id: 8a593577322922c6f6f0f96dd5cb0761c3035389
2022-09-07 04:37:17 -07:00
Luke De Feo
0426966b14 Additional test activities
Summary: Some activities for testing the UI debugger

Reviewed By: lblasa

Differential Revision: D39208140

fbshipit-source-id: a6fcc1f082df5dc61f72019f92a6307d0e90176e
2022-09-07 04:37:17 -07:00
Luke De Feo
41068d1c90 Native UI scan
Summary: Added scheduler to scan the Native UI every 500 ms to test, Also added instrumentation in a separate event with the timings of each stage visualised in a Data table on desktop which can be accessed with ctrl+I. Currently this instrumentation event is sent every time but it could be a config option controlled from the desktop in the future

Reviewed By: lblasa

Differential Revision: D39205313

fbshipit-source-id: ca034171db6b062396b4ef28028aaa663c4d852a
2022-09-07 04:37:17 -07:00
Luke De Feo
a5da6923eb Flatten layout during traversal
Summary: Move from a nested structure to a flatten one for data exchange, this will allow us to only send sections of the UI in the future

Reviewed By: lblasa

Differential Revision: D38982138

fbshipit-source-id: d578a07a6d2d7e117fbd741bd6e33062223ce10d
2022-09-07 04:37:17 -07:00
Luke De Feo
f123e65e8f Added strongly typed tree for sidebar inspector
Summary:
Introduced a JSON like tree structure for the sidebar insepector. Descriptors can provide their data as well as  if its mutable or not.

Enum mapping was simplified

Reviewed By: lblasa

Differential Revision: D38947238

fbshipit-source-id: cd8a6a8a752c5f626582ab8ac5efae6e9ff6a2ad
2022-09-07 04:37:17 -07:00
Luke De Feo
c854d0a2bb Added kotlin serialization
Summary: ^

Reviewed By: lblasa

Differential Revision: D38976576

fbshipit-source-id: 32022c263a0c81e6e99478375592ef1be9fea1cf
2022-09-05 05:36:23 -07:00
Yizhe Chen
09e81b19ad fix strict mode exemption to allow disk write as well
Summary: Filpper is doing disk IO on UI thread which actually produce `DiskWriteViolation` (presumably when the directory is not there, it will write to create)

Differential Revision: D39196484

fbshipit-source-id: f6b15785ea6ecf3ea5b41211908c14eac3d1309e
2022-09-01 17:39:49 -07:00
Lorenzo Blasa
947d00c6c3 Fix send raw messages
Summary:
^

The last change removed the overload of `send` in favour of `sendRaw`

Reviewed By: LukeDefeo

Differential Revision: D38946386

fbshipit-source-id: c4491c4afe4d719602c99878dc7185d436179aef
2022-08-24 11:17:21 -07:00
Lorenzo Blasa
1b2f875cc6 Scheduler
Summary:
Add a simple scheduler which operates in the following way.

There are two type of tasks: main, background.

The main task will run on the main thread whilst the background task will run on a background thread.

The main task will be executing at a fixed internal whereas the background task will get queued on demand but can effectively consume what was produced by the main task at its own rate.

Reviewed By: LukeDefeo

Differential Revision: D38975283

fbshipit-source-id: 0633385d2938705a16f5fc75a28cad067e4a8e55
2022-08-24 09:03:39 -07:00
Lorenzo Blasa
5aff69d1c9 traversal
Summary: This adds a simple traversal to the UI. As it stands, it will most likely be updated in future iterations.

Reviewed By: LukeDefeo

Differential Revision: D38907292

fbshipit-source-id: 98cea1f971a4ef37ba2d1c75b882dd44df29bb3a
2022-08-23 05:45:29 -07:00
Luke De Feo
f1e80b18b1 Basic desktop plugin
Summary:
Scaffolded desktop UI for UI debugger
I changed getroot from an rpc call to an event sent on connect. The root should never change as its the application object.

Reviewed By: lblasa

Differential Revision: D38866008

fbshipit-source-id: ca0f1908bedb643238f11ed796922e3359619167
2022-08-22 03:02:53 -07:00
Lorenzo Blasa
6adf1d666f Descriptors
Summary:
Introducing descriptors. Taken from the existing inspector, refreshed with a few things from Stetho, and translated to Kotlin.

Note: doesn't use FlipperObject or FlipperArray.

This is a very rough draft for them all, but can be used as basis for experimentation.

Reviewed By: LukeDefeo

Differential Revision: D38860763

fbshipit-source-id: 9f6bf4ad0e61fc40b0a773dfb8bfa80b1f397b3a
2022-08-19 08:47:58 -07:00
Lorenzo Blasa
b5bdd56d2c Application to instantiate Plugin
Summary:
Plugin needs both the Context and Application. Application is Context. Pass Application.

:)

Reviewed By: LukeDefeo

Differential Revision: D38831033

fbshipit-source-id: ff12a8ddc875fb54389e591a1c1c9febedb3aa37
2022-08-19 08:47:58 -07:00
Adam Ernst
0aa1f14536 Remove @scarf-generated from xplat/sonar
Summary: See D38829381.

Reviewed By: d16r

Differential Revision: D38837720

fbshipit-source-id: c576e16ebb5a0afd5e6dfc71adb3cf0c2361e9a3
2022-08-19 05:54:13 -07:00
Lorenzo Blasa
dc28e2ad45 ApplicationRef
Summary:
Introduce ApplicationRef which holds a reference to Application. It exposes a few utility methods to get view roots and activities.

ApplicationInspector has a few template methods for useful things which are not used in this diff and most likely will either be moved/deleted/changed on the final implementation.

Reviewed By: LukeDefeo

Differential Revision: D38829523

fbshipit-source-id: b8aeb133dceb3af42b5f7d6851ef531d35fc7d69
2022-08-19 05:08:49 -07:00
Lorenzo Blasa
769a1844b7 Common types
Summary:
EnumMapping and InspectableValue taken from the original 'inspector' plugin but translated to Kotlin.

Accumulator is just a Map<String, Any>

Reviewed By: LukeDefeo

Differential Revision: D38823678

fbshipit-source-id: 6af395cab2e3e6930575eb63d22d660dab962fde
2022-08-19 03:39:06 -07:00
Lorenzo Blasa
d1c06c9c46 Do not overload send as this causes issues with folly::dynamic
Summary:
folly::dynamic, std::string, implicit constructors and method overloading is not a good combination.

This renames the send method to sendRaw as to avoid issues with existing plugins currently sending string params.

Reviewed By: mweststrate

Differential Revision: D38827539

fbshipit-source-id: 653f62e41ebfbe93d1af25f39c81f6b05bf84cb4
2022-08-18 09:39:42 -07:00
Lorenzo Blasa
543ea489db Stetho-bits
Summary:
^
From: https://github.com/facebook/stetho

The copies used by the original plugin were located at: https://www.internalfb.com/code/fbsource/[a8a0c1be09a9]/xplat/sonar/android/src/main/java/com/facebook/flipper/plugins/inspector/descriptors/utils/stethocopies/

In addition, copies were translated to Kotlin, and adjusted accordingly.

Reviewed By: LukeDefeo

Differential Revision: D38783216

fbshipit-source-id: 2375bd94d333a2edb6156602b47dee32c83472ff
2022-08-18 05:16:38 -07:00
Lorenzo Blasa
ece57689e5 Move to public plugins location
Summary:
^

So far, we had the 'uidebugger' plugin as a meta-only plugin.

This change moves the plugin to OSS space as it will ultimately be its right place.

It will also make it easier to iterate on it.

The plugin itself is not ready for consumption but at no point we are documenting or integrating it with our samples.

Reviewed By: passy

Differential Revision: D38742336

fbshipit-source-id: 5cf124722fa7ba75ee9b998c507bfdfb2e4782c1
2022-08-18 05:16:38 -07:00
Lorenzo Blasa
3b8e74d16f Add kotlin support
Summary:
^

changelog: Add kotlin support for the android library

Reviewed By: LukeDefeo

Differential Revision: D38746572

fbshipit-source-id: f49534072eee3854368ea6f725e726560c03d76e
2022-08-18 05:16:38 -07:00
Lorenzo Blasa
c2ed2484d9 Expose a send method with a string params
Summary:
For C++, folly::dynamic is used throughout.

On iOS and Android though, Flipper goes through multiple conversions to get to a folly::dynamic only to ultimately obtain a JSON string from it.

Let's take a look at Android:

There are multiple types like FlipperObject, FlipperArray that wrap around a JSONObject.

When data needs to be sent:
1. The JSONObject is asked for its string representation.
2. The string representation is then parsed by folly to construct the folly::dynamic instance.
3. The step above involves an extra boundary cross through JNI.
4. Ultimately, a socket or ws connection does not understand folly::dynamic so we then get a JSON string representation from it.
5. Data is sent.

As described above, for big enough objects, this represents an issue.

So, the idea of this change, is to allow plugins to send a JSON string instead. This will remove a few serialisation/deserialisation steps from the process.

*Note: this API is not currently used by anything so there's no impact to existing plugins.*

Changelog: expose a send method that accept a string as params

Reviewed By: LukeDefeo

Differential Revision: D38741582

fbshipit-source-id: 78e0acd80fc8c97378ee986cbaf377078996ed60
2022-08-17 09:18:20 -07:00
Zac Sweers
64c32f62b1 Tag sockets in FlipperSocketImpl (#3928)
Summary:
Resolves https://github.com/facebook/flipper/issues/3926. Open to suggestions on the tag value, just sort of picked one that could be pointed to for anyone that wants to track these in their apps.

## Changelog

Tag sockets used by Flipper to fix strict mode warnings about untagged sockets.

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

Test Plan:
Edit FlipperSampleApplication.java with the following:

```
public class FlipperSampleApplication extends Application {
  Override
  public void onCreate() {

    StrictMode.setThreadPolicy(
            new StrictMode.ThreadPolicy.Builder()
                    .detectAll()
                    .penaltyLog()
                    .build()
    );
    StrictMode.setVmPolicy(
            new StrictMode.VmPolicy.Builder()
                    .detectAll()
                    .penaltyLog()
                    .build()
    );
...
```

That will enable strict mode. Now build/launch the sample application.

Use adb logcat to inspect warnings:

```
 adb logcat -s StrictMode
```

Without tagging the socket, the following warning should be observed:

```
D/StrictMode: StrictMode policy violation: android.os.strictmode.UntaggedSocketViolation: Untagged socket detected; use TrafficStats.setTrafficStatsTag() to track all network usage
```

After applying the fix, that warning should go away.

Reviewed By: lblasa

Differential Revision: D38280819

Pulled By: passy

fbshipit-source-id: 0c841b13237cbcb0ff8b8226fb44655a74b775c6
2022-08-01 08:34:00 -07:00
Lorenzo Blasa
2916a5fa52 Remove unused code
Summary:
A codemod removed a GK which resulted in this...

This change removes the unused code.

Reviewed By: mweststrate

Differential Revision: D38239893

fbshipit-source-id: 01163e9f5adcc77fff572b47ce1d902dbdadff4d
2022-07-28 06:59:11 -07:00
Luke De Feo
f72406b06c Ensure that highlight always responds to prevent timeouts
Summary: In a previous diff D32278523 (8764da7c0b) The desktop request was changed from send to call. Call expects a response and not all code paths return a response. Most calls to set highlight are timing out.

Reviewed By: mweststrate

Differential Revision: D38074704

fbshipit-source-id: 6e85416d6b6470efaa177ad1b74420c8237366d5
2022-07-25 14:51:41 -07:00
dependabot[bot]
a752b4711d Bump core-ktx from 1.7.0 to 1.8.0 (#3794)
Summary:
Bumps core-ktx from 1.7.0 to 1.8.0.

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=androidx.core:core-ktx&package-manager=gradle&previous-version=1.7.0&new-version=1.8.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/3794

Reviewed By: lawrencelomax

Differential Revision: D37070913

Pulled By: passy

fbshipit-source-id: 98f817ee76bde2dfec2ebf3eb5080214c746cdc4
2022-06-13 08:29:14 -07:00
Harshit Bangar
c88e769013 Prototype: Added support for multiple host in mock (#3762)
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
2022-06-06 12:40:55 -07:00
Lorenzo Blasa
e44cad5e99 Partially remove dependency on folly async
Summary:
This change isolates the usage of folly async from Flipper. Is now self-contained in Flipper Folly schedulers.

Users of Flipper can decide not to use the types defined in that header and implement their own.

NOTE: changes are minimal, we are just replacing direct calls to folly event base with a scheduler which simply relays this on to folly.

Reviewed By: fabiomassimo

Differential Revision: D36626483

fbshipit-source-id: add0241caf4af0aa5c3b5c2e7efc2e725f5400ab
2022-05-25 15:58:05 -07:00
Michel Weststrate
18d64f9631 Fix NPE during search
Summary:
`getChilAt` can return `null` (see also line 671), probably when the UI changes during the inspection process. Added a null check that should protect against the failure reported in P501013941

Changelog: Fixed NPE during search in layout plugin (Android)

Reviewed By: lblasa

Differential Revision: D36369508

fbshipit-source-id: 1f066d1a73bdfe875d66f7200ded0d0776af8321
2022-05-13 07:08:52 -07:00
Billy Ng
3804ccf898 Revert D36052198: Partially remove dependency on folly async
Differential Revision:
D36052198 (ade685c621)

Original commit changeset: 170d64a324a1

Original Phabricator Diff: D36052198 (ade685c621)

fbshipit-source-id: 69d2b18e70a6267667432d6ed9dc1c5bc545b417
2022-05-12 18:47:41 -07:00