Commit Graph

570 Commits

Author SHA1 Message Date
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
Luke De Feo
46824f3369 Fix flipper connect / disconnect cycle
Summary: Previously we were cancelling the entire context which meant after reconnect nothing was sent. Additionally we now close / reinitiaze the channel so that any old events are not sent on reconnect

Reviewed By: lblasa

Differential Revision: D39658945

fbshipit-source-id: bb02724434aa820d811b49ab799a4643ab7e785a
2022-09-21 07:02:48 -07:00
Lorenzo Blasa
aa801b6715 Fix bug introduced with variable rename
Summary:
^

`mutableClass` should be used instead of `clazz`

Reviewed By: LukeDefeo

Differential Revision: D39652102

fbshipit-source-id: 8ba86d39796beed79ff7cf8b37f3460facc38430
2022-09-20 06:35:48 -07:00
Lorenzo Blasa
1cc71af832 Fix typo for initialiser
Summary: ^

Reviewed By: antonk52

Differential Revision: D39575995

fbshipit-source-id: 2e95d43c37e2341e9e6f723282d829d06f1b1c5d
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
d85e8a0949 TreeObserverFactory, change file name to match type
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39575384

fbshipit-source-id: 30ca896d93c4f3641f748123af024354c10de8b8
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
7f103ee293 TreeObserver tidy up
Summary:
Remove usage of '!!', it is generally discourages even though instances are guaranteed to exist.

Adjust comments

Reviewed By: LukeDefeo

Differential Revision: D39575368

fbshipit-source-id: a159a0411a913de3d1ae6236c41ea15255687433
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
83f8a0675c Adjust spaces
Summary: ^

Reviewed By: LukeDefeo

Differential Revision: D39575336

fbshipit-source-id: b9c2cf75d674a3ee86dc26f918fc0d9130bc8dc0
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
1744335ddd View as weak reference
Summary: Keep a weak reference of the view instead of a strong reference.

Reviewed By: LukeDefeo

Differential Revision: D39575312

fbshipit-source-id: ae8df7d089b29ea3b1cf960a6ae020ed5a9c3648
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
2051359490 Unsubscribe from updates and tidy up
Summary: Remove listener on unsubscribe and tidy up comments.

Reviewed By: LukeDefeo

Differential Revision: D39575287

fbshipit-source-id: 2b4ac0bc07cfe86f5ad0e602bbba4b596230cd52
2022-09-20 05:15:50 -07:00
Lorenzo Blasa
ddc5554673 Suppress warnings for RootViewResolver
Summary:
^

There's no way to address these warnings, so suppress.

Reviewed By: LukeDefeo

Differential Revision: D39575262

fbshipit-source-id: 6703476d7637c63aa9a81b26f8cdbd0f53e3991c
2022-09-20 05:15:50 -07:00
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