Commit Graph

608 Commits

Author SHA1 Message Date
Luke De Feo
a4d3167fae Application, window and activity all inherit window bounds
Reviewed By: lblasa

Differential Revision: D41218326

fbshipit-source-id: aa0fad5c80e482629a70240da81c347217d12ea7
2022-11-14 07:05:58 -08:00
Lorenzo Blasa
7ae0eac13a Litho Props
Summary:
This diff adds support for layout and component props from Litho.

Notes:
- Each component could register a descriptor for itself.

Reviewed By: LukeDefeo

Differential Revision: D40680095

fbshipit-source-id: 57c78a199db58e05dd6dac4ed32ff6a869a73b0a
2022-11-11 04:49:02 -08:00
Lorenzo Blasa
f33e3fc78b Add qualified name to Node
Summary:
Our descriptors currently have a method to return the name as it will be displayed on the elements hierarchy.

However, it doesn't provide enough context if the name is to be used to discover the type in our code base.

This change adds a qualified name method that can provide a more complete name which can indeed be used by the Open In IDE functionality, for example.

Reviewed By: passy

Differential Revision: D40936785

fbshipit-source-id: 790ae02b9ebf37501765c52a24307fcaaaf9c14d
2022-11-11 03:22:39 -08:00
Lorenzo Blasa
01dc22b1ab Attributes Metadata
Summary:
Before this change, attributes and attribute metadata were intermingled and sent as one unit via subtree update event.

This represented a few issues:
- Repetitiveness. For each declared and dynamic attribute, metadata was included on each value unit.
- Metadata can vary in size and thus can have a negative impact on payload size.
- The attribute name which is part of metadata is a string which always overhead on processing.
- Metadata instantiation is not cheap thus this also incurs in processing overhead i.e. even instantiating a single string can have an impact.

The proposal is to separate metadata of attributes from the actual node reported attributes. This solves the problems mentioned above.

Reviewed By: LukeDefeo

Differential Revision: D40674156

fbshipit-source-id: 0788551849fbce53065f819ba503e7e4afc03cc0
2022-11-10 11:52:28 -08:00
Akinola Orederu
42ecf919d6 removing null values for bindArgs so database plugin doesn't throw exception for beta builds
Summary:
Removing use of ```database.query``` with null values because its stopping the database plugin from working for whatsapp android.

The [release version of FrameworkSQLiteDatabase](https://androidx.tech/artifacts/sqlite/sqlite-framework/2.2.0-source/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java.html) is written in java which accepts a null value (although its still annotated NonNull for Object[] bindArgs)

But the [beta version of FrameworkSQLiteDatabase](https://androidx.tech/artifacts/sqlite/sqlite-framework/2.3.0-beta01-source/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.kt.html) is written in kotlin which throws an exception for null values.

Reviewed By: passy, mweststrate

Differential Revision: D40870552

fbshipit-source-id: 72c99c1b62d052887d298145a3019d6123ea94f3
2022-11-01 09:41:25 -07:00
Lorenzo Blasa
3598fb2cde Use correct bounds for litho debug components
Summary:
This change is a follow-up on Litho release:
https://central.sonatype.dev/artifact/com.facebook.litho/litho-widget-kotlin/0.44.0

This change ensures DebugComponent returns the correct Bounds.

Reviewed By: aigoncharov

Differential Revision: D40678191

fbshipit-source-id: 1d587efa114a9cd5c0b8162d219e93e3cbad282e
2022-10-28 04:58:52 -07:00
Luke De Feo
b1bee28f08 Coordinate update event when litho scrolls or is shifted
Summary: See doc comment for explanation

Reviewed By: lblasa

Differential Revision: D40587610

fbshipit-source-id: f0909440c4e6e3cc9f5c7b557198a93ba8809bd9
2022-10-25 07:10:38 -07:00
Luke De Feo
a447712865 Change Litho observer from on scroll changed listener to on draw listener
Summary:
There are some situatuins where a litho view can move  without a mount occuring in that view. One situation is a litho view in a recycler view. If a neighbouring view is deleted or changes its width/height this will shift the whole recycler view. Since each view in the recycler view is typically a separate comonent tree. The children of the recycler view are not aware of their siblings changes through mount. And these situations do not count as a scroll which was the previous method of detecting change.

This is a work around to listen to on draw which seems to be fired in all situations.

Reviewed By: lblasa

Differential Revision: D40430777

fbshipit-source-id: a9c8196f31a6bdfd4a2fed398cfcaed190972959
2022-10-25 07:10:38 -07:00
Luke De Feo
1aacc51d12 Use mount extension for litho integration
Summary:
Initial implementation of Litho extensions using mount extension. After mount is called on the main thread and we traverse the hierachy. In future we can use mount extensions to construct a sparse tree rather  than sending everything every time.

Scroll is handled with a native UI scroll listener for each litho view. This may break if the litho view is not a direct child of the scroll view.

Reviewed By: mihaelao

Differential Revision: D40021840

fbshipit-source-id: b09086a7a16660225885620609009dddf5b90d3b
2022-10-25 07:10:38 -07:00
Luke De Feo
7c3e28272b Override bounds for view pager
Summary: For view pager we just want to draw the content in the center

Reviewed By: lblasa

Differential Revision: D40478266

fbshipit-source-id: 4fac7e897a0569fed59ef5810ba15300ebe87b5d
2022-10-25 07:10:38 -07:00
Luke De Feo
62167bb69c Fix bounds for children of nested scroll view
Summary:
Android does not set the top/left of the child of view pager. I attempted to solve this by grabbing the offset from the scrollview and passing it down via offset child. The issue is offsetchild has a lot of problems with the partial layout traversal. If the child of the scroll view is an observer root then the layout traversal with short circuit and setup a new observer for the child but we lose the offset child in the process.

This solution is a little dirty but it is functional for now

Reviewed By: lblasa

Differential Revision: D40430778

fbshipit-source-id: 7ad53b2a4818b55515e7662272548e2ce17e6b44
2022-10-25 07:10:38 -07:00
Luke De Feo
a0d1013b94 Dont emit mounted drawables for litho
Summary: Getting the boxes to line up is quite hard to do right and has undetermined value

Reviewed By: mihaelao

Differential Revision: D40430776

fbshipit-source-id: 6093c4874f39ecf0c673407da2bd03ef06ca017e
2022-10-25 07:10:38 -07:00
Lorenzo Blasa
38109eccff Active children and fragments bug
Summary:
Getting the active child was only ever returning the actual active View.

This is correct. However, if the View is backed by a Fragment, then the child is reported as Fragment instead of the actual View.

This was an issue as effectively, the reported children (fragments) were never going to match the active child (view).

Additionally in this change, report back the name of the node even if not active.

Reviewed By: LukeDefeo

Differential Revision: D40632526

fbshipit-source-id: 3560b193b370f19ceabe66980fe23f55ec887274
2022-10-25 03:09:00 -07:00
Lorenzo Blasa
bb3b1cecef Simple antd types for each inspectable type
Summary:
Replace draft inspectors with read-only components.

This is a first step into having a richer UI. At the moment, these are read-only components but will likely be extended in the future as to allow editing of values.

Reviewed By: LukeDefeo

Differential Revision: D40345016

fbshipit-source-id: a6aef5861474b4aa8353c00ef257ab17b4cff00e
2022-10-25 03:09:00 -07:00
Jordan Smith (IGDS)
d28aab50d7 Calculate talkback role based on supported paging actions
Summary:
Google Talkback identifies nodes with supported actions up, down, left and right to be of the role Pager.

Reference here: https://github.com/google/talkback/blob/master/utils/src/main/java/com/google/android/accessibility/utils/Role.java#L376-L385

This diff give us the ability to correctly calculate those roles when we come across them in flipper

Reviewed By: blavalla

Differential Revision: D40449485

fbshipit-source-id: 5a9dfe3f807b7fce8043eaab2695d864f93a1392
2022-10-18 15:52:10 -07:00
Lorenzo Blasa
0572808f1a Add additional inspectables
Summary:
This change adds support for more inspectables and also introduces more complex types to be used as a value.

This become specially useful for more complex yet primitive types like coordinate, size, bounds, etc.

Reviewed By: LukeDefeo

Differential Revision: D40307885

fbshipit-source-id: 125e832f06d6b31f56eb5405182d1c0d61388930
2022-10-18 04:30:51 -07:00
Luke De Feo
9cbf35dea8 Consider local visible rect and translation when calcauating view bounds
Summary: In general we want a child to know its position without having be overriden by it parent via offset child. Therefore we need to consider translation and the result of getLocalVisibleRect. Despite its name it seems to be an offset from its normal bounds after scrolling in certain types of scroll views.

Reviewed By: lblasa

Differential Revision: D40021836

fbshipit-source-id: 4ae9a4b202d7ba201cdb8b6bc8f13e94baf2b37e
2022-10-10 04:13:06 -07:00
Luke De Feo
9f6ba6cf8c Fix issue where tree observer always subscribing
Summary: This was causing all observers to continuously traverse all children since most observers traverse on subscribe

Reviewed By: lblasa

Differential Revision: D40021835

fbshipit-source-id: 6a6fba02523848be37f5e939c7a240ff2958daca
2022-10-10 04:13:06 -07:00
Luke De Feo
b911c49667 Additional Litho descriptors
Summary: Moved to separate directory. These additional descriptors are useful for debugging the implementation but might not be useful for the end users so could potentially be removed down the road

Reviewed By: lblasa

Differential Revision: D40021834

fbshipit-source-id: f88c1186dd65cdabc816d5cd8256bb81c404a80c
2022-10-10 04:13:06 -07:00
Luke De Feo
221f7ac1e5 Generalised mounted object and descriptor into offset child
Summary: There are other situations where we want to overide the offset than for litho mounted views

Reviewed By: lblasa

Differential Revision: D40021833

fbshipit-source-id: 1411a4a67e88f6893bb38e36fb6a81eead3edd1a
2022-10-10 04:13:06 -07:00
Luke De Feo
c9983edb1a Fix superclass chaining when adding descriptor late
Summary: External frameworks such as litho add their descriptors with register descriptor, we need to make sure that we set up the superclass chaing for these

Reviewed By: lblasa

Differential Revision: D40021843

fbshipit-source-id: 41666e5e3a31f249f7dfd550c15d747d394d2a8f
2022-10-10 04:13:06 -07:00
Luke De Feo
de1eece900 Removed chaining of children from chained descriptor
Summary: This chaining needed to be removed to allow for litho view to override the children to be the root debug component

Reviewed By: lblasa

Differential Revision: D40021839

fbshipit-source-id: 1caf30ced14cf582f9e03e87e15f9a8eda5b9c4f
2022-10-10 04:13:06 -07:00
Luke De Feo
8140244f0a Fix null reference error in text view descriptor
Summary: Thanks java / google

Reviewed By: lblasa

Differential Revision: D40021844

fbshipit-source-id: 19d7d04bf8c637964ef6bea5b28224d7b5134c3f
2022-10-10 04:13:06 -07:00
Luke De Feo
23ab1e9127 Added value animator button
Summary: This is usefull to make sure the ui debugger sees changes from value animators

Reviewed By: lblasa

Differential Revision: D40021838

fbshipit-source-id: 1fe18b79a89b43f286aa4e90aa6e850db3e887a5
2022-10-10 04:13:06 -07:00
Luke De Feo
1fd1029a3d Background plugin
Summary: When running in the background in a large app like fb4a it can take a while to reprocess all the events, we can revisit this in the future

Reviewed By: lblasa

Differential Revision: D40021842

fbshipit-source-id: 8e5300e0f8534525bd184c029e523f05f4076695
2022-10-10 04:13:06 -07:00
Lorenzo Blasa
76d6350662 Set jvm flags and kotlin dependencies (#4177)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/4177

^

In an attempt to fix Github actions, may or may not work.

Reviewed By: aigoncharov

Differential Revision: D40074397

fbshipit-source-id: e88039c56876ca21657db4a6d872c46294a4f8c3
2022-10-05 04:30:17 -07:00
Lorenzo Blasa
16983deaaf Upgrade gradle plugin (#4166)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/4166

^

Changelog: Upgrade to gradle plugin 7.3.0

Reviewed By: LukeDefeo

Differential Revision: D40019423

fbshipit-source-id: ab05fd73e942c96601e2291049b1c858408e1192
2022-10-03 07:35:43 -07:00
Luke De Feo
277d730f77 Improve Textview descriptor
Summary: Also removed button descriptor as android doesnt expose anything usefull

Reviewed By: lblasa

Differential Revision: D39732772

fbshipit-source-id: 38d5d2290abf7103650e4260ae1169d8d53b1d9b
2022-09-29 05:31:18 -07:00
Luke De Feo
740f4b3fdc Add basic drawable descriptor
Reviewed By: lblasa

Differential Revision: D39731553

fbshipit-source-id: 77a8ff244b63e2f14c671bbff6c18dbe3ec25257
2022-09-29 05:31:18 -07:00
Luke De Feo
7ae2c35476 Remove redundant native scan event
Summary: It didnt need to exist and can be seen as a subtree update of type full scan

Reviewed By: lblasa

Differential Revision: D39731552

fbshipit-source-id: e351413d9480e118fc000c5e55eae0e7980233f2
2022-09-29 05:31:18 -07:00
Luke De Feo
78e84a0cc3 added metrics for snapshot
Reviewed By: lblasa

Differential Revision: D39886448

fbshipit-source-id: b229f6947d199026c6e4bdc89def6ac0a0fa9d0a
2022-09-29 05:31:18 -07:00
Lorenzo Blasa
8bb711ddfb Use chained descriptor for snapshots
Summary:
This change removes the getSnapshot implementation from ViewGroupDescriptor.

Instead we rely on the chain implementation to get one.

Once we do get a snapshot, return.

Reviewed By: LukeDefeo

Differential Revision: D39849484

fbshipit-source-id: bfa0b1af22cf501777687295b8d792f8144a8d3b
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
ff3fb338ab Use coroutine instead of Handler
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39848640

fbshipit-source-id: 31e9ecc6e52105c61c8765d5d8b4c2c493026416
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
fadaf26f1e Single bitmap pool with view size changes support
Summary:
This change aims to reduce the number of bitmap pools by definiting a default pool which can contain bitmaps of different sizes.

A side benefit is that this single pool facilitates handling the case where a view gets resized too.

So overall, this should be both more generic and efficient compared to the previous approach.

Reviewed By: LukeDefeo

Differential Revision: D39815821

fbshipit-source-id: e0aa17ba55db07b74d8f22ea16e0c864288fb169
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
433061d377 Take snapshot on subtree update
Summary:
DecorView owns a BitmapPool to take snapshots of the view. These snapshots are later on serialised by the manager.

There's a couple of unrelated changes in this diff but that were already in place making it hard to split.

(1) Renamed 'traverseAndSend' to 'processUpdate'. Why?

The observers as a whole shouldn't necessary know that their 'observation' is being sent to any place. Future changes should move the send logic altogether from the observer too. But that can be made within the scope of a different diff.

(2) There was a bug for nodes that were being observed but then unsubscribed from. If the nodes were being marked for observation and observer was already into place, these were not being told to subscribe again for changes.

Reviewed By: LukeDefeo

Differential Revision: D39812943

fbshipit-source-id: af98c5caf54e1c69f97043bae95049395a2e4545
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
7017d74821 Cleanup plugin class implementation
Summary:
Remove unnecessary/unused code.

Changed 'uidebugger' -> 'ui-debugger' to match plugin identifier.

Reviewed By: LukeDefeo

Differential Revision: D39812777

fbshipit-source-id: a6010b69cc1d5812ecbe644344efa27bf8ab7cd0
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
08b3489201 Improve getSnapshot
Summary: Addresses a few issues with the existing implementation.

Reviewed By: LukeDefeo

Differential Revision: D39812624

fbshipit-source-id: 6f955f62bc5a7943558541e4cf7b4ccba4fd9be3
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
e7742169f5 Move traversal outside of observers package
Summary: Move partial traversal to the traversal package

Reviewed By: LukeDefeo

Differential Revision: D39812542

fbshipit-source-id: 1efa6f83ce53c49f3d06574cf52b8d065cb0fe22
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
cd7cc37fd3 Bitmap pool
Summary:
Bitmaps are not cheap to create. Also, bitmaps are used from the main thread to capture the contents of a view but can be used and processed by background threads.

BitmapPool aims to solve both problems.

- It is a pool that can be used to recycle bitmaps.
- The recyclable bitmap can be processed by a background thread which can explicitly recycle the bitmap once done with it, hence putting it back into the pool.

UPDATE: D39815821

That diff changes the approach by defining a single default pool which can handle bitmaps of different sizes.

Reviewed By: LukeDefeo

Differential Revision: D39812212

fbshipit-source-id: 065eea656f4139aeb9d09cd5a5c7dddfc9c8edfd
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
6f65517933 getSnapshot
Summary:
This change introduces a new Descriptor method to obtain snapshots of an item in the layout hierarchy.

Only implemented by the ViewDescritor but it can be potentially extended to Windows, Fragments, Activities, ...

Reviewed By: LukeDefeo

Differential Revision: D39690548

fbshipit-source-id: cf3a1ccd63eb28c1de328310e8635829a40964dd
2022-09-26 06:03:49 -07:00
Lorenzo Blasa
48f70ef8ec PartialTraversal
Summary:
Cleanup documentation as with the other traversal, no raw loops.

Note: about no raw loops philosophy

To make clear and explicit the intention of the code, in this case to iterate over all elements of a collection.

A raw loop exposes unwanted flexibility which makes it hard to reason about code. A raw loop body thus have control over the lifetime of the loop itself.
- continue
- break
- return

None of those can be used with a forEach for example. Thus we make it clear the intention of the code.

Reviewed By: LukeDefeo

Differential Revision: D39652960

fbshipit-source-id: ac660dc43256e7850bd18e31b00aa123783d5c98
2022-09-26 05:00:36 -07:00
Jacy
5b794dc28f Fix: [Android] Flipper Leakcanary plugin's OnHeapAnalyzedListener has been deprecated (#3923)
Summary:
Flipper Leakcanary plugin's OnHeapAnalyzedListener has been deprecated.

Flipper Leakcanary plugin's OnHeapAnalyzedListener has been deprecated change to EventListener implement.

## Changelog

1. add FlipperLeakEventListener.kt to implement EventListener.
2. update doc

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

Test Plan:
Setup the  Leakcanary plugin use FlipperLeakEventListener, test if it works.

**Static Docs Preview: flipper**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39652084/V4/flipper/)|

|**Modified Pages**|

Reviewed By: antonk52

Differential Revision: D39652084

Pulled By: antonk52

fbshipit-source-id: 0afeb52dce6c1749a894a15dbb7921580c094ae6
2022-09-22 05:57:28 -07:00
Luke De Feo
9bc2f6fec5 Remove node Id from descriptor
Summary: It was always the system hash code and in many places it was inconvient to get the descriptor to just end up calling the same function

Reviewed By: lblasa

Differential Revision: D39700215

fbshipit-source-id: b1439d56cd8f39ba8735f933662ad79b87ffbdbe
2022-09-22 04:26:18 -07:00
Luke De Feo
32b7a5589f Remove layout traversal
Summary: The old full traversal was not needed as the partial traversal is a superset of the functionality and it was a pain to maintain both

Reviewed By: lblasa

Differential Revision: D39700216

fbshipit-source-id: 0b028995a59f7c5ea4318add8b0534851ca99547
2022-09-22 04:26:18 -07:00
Luke De Feo
ed662d2468 Fixed bounds for native views mounted by litho
Summary: We had an issue where the offset for a native view was effectively caclculated twice and summed, once by litho and once by android. Given the UI debugger expects a nodes bounds to be w.r.t its parent the android systems x,y offset is 'wrong' from ui debuggers perspective, we set it to 0,0 and rely on the calculated offsets by the litho component hierachy

Reviewed By: lblasa

Differential Revision: D39695663

fbshipit-source-id: d9c2be950fc68bc2286359a62746356e89299cfd
2022-09-22 04:26:18 -07:00
Lorenzo Blasa
060f8911b1 Add documentation to ActivityTracker initialisation
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39652590

fbshipit-source-id: e97a365f56dbecaaebf3a54a1325ad6b65839660
2022-09-21 13:28:17 -07:00
Lorenzo Blasa
cae15276f5 Throttle with wait
Summary: Throttle events whilst keeping track of latest

Reviewed By: LukeDefeo

Differential Revision: D39652348

fbshipit-source-id: 9c8fb5a1bb92872985f46a62d79c6594a37e8340
2022-09-21 13:28:17 -07:00
Luke De Feo
80b05092ac Add bounds and tags to descriptor
Summary: This is to support a future diff where we will draw a basic wireframe for debugging

Reviewed By: lblasa

Differential Revision: D39509407

fbshipit-source-id: d99fd6fe39404996a0ed944c10905331262fd0c6
2022-09-21 07:02:48 -07:00
Luke De Feo
c09e185867 Set target SDK version for buck build
Summary: It was building at target sdk 0 before which lead to various checks failing, in future when these checks fail we should send a notification to flipper

Reviewed By: lblasa

Differential Revision: D39652095

fbshipit-source-id: 748bc74f0b5745011e6289e5582405149df8357f
2022-09-21 07:02:48 -07:00
Luke De Feo
7deb374c1c Add initial decor view traversal
Summary: Catch the case when we mis the initial draw

Reviewed By: lblasa

Differential Revision: D39658946

fbshipit-source-id: 00a46226128e28a8753df2161d1edcd6ffa47d67
2022-09-21 07:02:48 -07:00