Commit Graph

468 Commits

Author SHA1 Message Date
generatedunixname89002005325672
36cb69e1fd Daily arc lint --take KTFMT
Reviewed By: martintrojer

Differential Revision: D50964272

fbshipit-source-id: 1bdfffd1b32f76f2a81e95c6a59e15805a3a9436
2023-11-03 07:00:14 -07:00
Luke De Feo
3bb3ce6a66 Fix media gallery activity
Summary:
Weird edge case, this activity doesnt actualy contain the content and instead its in the decor view behind it, solution is to filter it out from traversal and snapshot

https://fb.workplace.com/groups/443457641253219/permalink/643518977913750/

Reviewed By: elboman, lblasa

Differential Revision: D50936817

fbshipit-source-id: 8c1e276d4d943c42c9c2085bf70113347cbd5c74
2023-11-02 12:29:07 -07:00
Luke De Feo
62e9181075 Improve logging
Summary: Lets make the logging higher signal

Reviewed By: passy

Differential Revision: D50853449

fbshipit-source-id: 95ebfbc142c34c36fb11e459c573842580cd6e4c
2023-11-02 12:29:07 -07:00
Luke De Feo
bd6e1285da Only pixel copy if view is hardwell accell
Summary:
You can only use pixel copy if the view is drawn by the hardware, this sort of makes sense as there is no hardware buffer to copy from.

we were falling back but there was a lot of noise in the logs

Reviewed By: lblasa

Differential Revision: D50853427

fbshipit-source-id: 9365a3d566a05de9082afb8bc2915922c624fd88
2023-11-02 12:29:07 -07:00
Luke De Feo
44b8a39874 remove common package
Summary: Just cleaning up some packages

Reviewed By: lblasa

Differential Revision: D50849169

fbshipit-source-id: 2b732e41ff11361dc7462598f282abb2d4116ce7
2023-11-02 12:29:07 -07:00
Luke De Feo
5b89331ea2 Fix case where traversal was out of sync with snapshot
Summary:
Its was possible for the view tree observer to be observing one root but this can a dead root with no view in it. As a result the snapshot will be empty and the observer will never fire.

The layout traversal Applicaiton ref descriptor had logic to handle these dead roots, this logic is now extracted and shared between the descriptor in the traversal and by the decor view tracker so they are in sync

Reviewed By: lblasa

Differential Revision: D50848155

fbshipit-source-id: ce6da13df40632cbb7a302a59382b4907131d9f5
2023-11-02 12:29:07 -07:00
Luke De Feo
d26612d840 Add modern snapshot approach
Summary:
Since api level 34 there is a way to snapshot any view, prior to this you needed a window which you can only get from an activity, or a surface which required hacks. The hacks are in place for older verisons of android but ive added modern pixel copy snapshotter for future proofing in case google decide to make any of the previously used hack not work in future version of android

Since there was a bunch of common code in each snap shot impl this has been pull into a utility function

Reviewed By: lblasa

Differential Revision: D50845284

fbshipit-source-id: c7910c45ff51fcf8636adc3d7272198ac3d4aefe
2023-11-02 12:29:07 -07:00
Luke De Feo
6e64f53046 Support pixel copy on views attached directly to window manager
Summary:
As mentioned in the previous diff pixel copy only support copying a Window, Surface or SurfaceView, All of these underneath use surface.

For views attached to the window manager there is no activity / window so we need another solution

There is no official way to get a views underlying surface so we had to do some dirty hacks to get it from the window manager. See the inline comments for details.

Additionally it turns out that the pixel copy api was actually made async in Android 34, so to prepare for this the snapshot method was made a suspend function and we wrap the callback based apit with suspendCoroutine.

Reviewed By: lblasa

Differential Revision: D50845281

fbshipit-source-id: 5ba8ed6f330c1e04549812a6493ae5f4cb629d1f
2023-11-02 12:29:07 -07:00
Luke De Feo
d85adc030f Use pixel copy on activities
Summary:
Pixel copy is a more reliable and consistent way to take a snapshot rather than drawing into a canvas. It accepts either:

Surface
SurfaceView
Window

For root views that belong to an activity its easy to get the window so we do that here.

In the next diff we solve this for other root views

Reviewed By: lblasa

Differential Revision: D50845282

fbshipit-source-id: 3968828dedd1e96a854b907e0fd152ad64993d95
2023-11-02 12:29:07 -07:00
Luke De Feo
6bf93347ee Extracted snapshot out of descriptor
Summary: Snapshot never made much sense in the descriptor since we only snapshot the decor views. Additionally in the next diff i will introduce a new way to snapshot so this will make it easier

Reviewed By: lblasa

Differential Revision: D50845280

fbshipit-source-id: c2eac351b72786e7b66951d0fa09cea52a6dcc69
2023-11-02 12:29:07 -07:00
Luke De Feo
c93c494ef4 Refactor android view observation
Summary:
The previous approach was designed for a world that didnt happen and was extremely confusing and allowed for states that didnt make a lot of sense. E.g it was possible we were snapshotting multiple views.

The new model is much simpler. we still depend on the root view resolver to tell us about root decor views but now we just attach a predraw listener to the top most view and push out the updates. This is handled by the new class decor view tracker which is a replacement for all the observer business

Additionally we use a conflated chanel in the update queue, this means if the background processing is slow we wont keep adding new frames to the queue, we just keep 1 and the most recent frame

Partial layout traversal -> Layout traversal as traversal is now always from top to bottom of the whole application

Reviewed By: lblasa

Differential Revision: D50791527

fbshipit-source-id: 43640723aefa775aa7b74065f405cc08224ed8b8
2023-11-02 12:29:07 -07:00
Brett Lavalla
254110bf02 Make 'none' AccessibilityRole return the class for View
Summary:
This changes the default behavior for a "NONE" accessibility role to match Googles implementation in ExploreByTouchHelper (https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/widget/ExploreByTouchHelper.java;drc=c7585d0e2f27f00c47802a78422228a81cf2c939;l=56?q=ExploreByTouchHelper).

This also matches ReactNative's default behavior here as well:
https://www.internalfb.com/code/fbsource/[199b5d1c47b224f2891b8cba33da90c5c8714a81]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java?lines=291

A role of "View" is a no-op behind the scenes for accessibility services, but making this a valid string rather than `null` will prevent potential crashed from systems expecting a string value to always exist from the "getClassName" method.

For context on how large of a potential problem this is, see this post:
https://fb.workplace.com/groups/sbteng/posts/1396301817590446

Reviewed By: ikenwoo

Differential Revision: D50864782

fbshipit-source-id: 8b176ed9427f62a1d039b012d10ea889df4777e3
2023-11-01 05:46:53 -07:00
Luke De Feo
21057fba01 Fix null pointer error
Summary: Turns out this can be null in some rare circumstances and can cause a crash in the fragment tracker

Reviewed By: aigoncharov

Differential Revision: D50562123

fbshipit-source-id: 4dfaecfde69359a85b778fc5ff0a4a3a8165a875
2023-10-24 05:49:56 -07:00
Joshua Selbo
cd4640326c Update tests on old SDK versions
Summary:
Preparing for next Robolectric version which drops support for SDK 16-18.

`MemoryToolsFlipperPluginTest` relies on JSON serialization order which changes when running on the latest SDK (33).

`InspectorFlipperPluginTest` has multiple issues when running on the latest SDK, so just bump it to 19.

Reviewed By: jiawei-lyu

Differential Revision: D50558702

fbshipit-source-id: 9724d8e699b703a9e0af12559c41e7053d820150
2023-10-23 11:02:31 -07:00
Luke De Feo
ee7f12ef85 Add message when traversal has error
Summary: By sending a message to the desktop we can report to log view and inform the user what happened

Reviewed By: lblasa

Differential Revision: D50369853

fbshipit-source-id: b4852d736232477261bfdf6f94c9395ce29cceaf
2023-10-19 03:33:42 -07:00
Luke De Feo
c3ad4f7180 Send warning when bloks tree not prepared
Summary: Give the user something actionable when tree is not ready due to flipper connected check failing

Reviewed By: lblasa

Differential Revision: D49455254

fbshipit-source-id: 8869cacde5b65260f4615f5ba2ba34f967d7d27f
2023-09-20 05:45:30 -07:00
Nate Stedman
ef621b07b7 Update ktfmt component on FBS:master
Reviewed By: hick209

Differential Revision: D49300079

fbshipit-source-id: 7e704e2366feee3f6f2c25ac25d3daea407e71f9
2023-09-15 07:19:43 -07:00
Lorenzo Blasa
ecc50f47e8 Clients to avoid sending payloads larger than the maximum allowed size
Summary: ^

Reviewed By: passy

Differential Revision: D48645400

fbshipit-source-id: ac262296f113298812803c12eccf5a37da1da2b7
2023-08-24 10:05:17 -07:00
generatedunixname89002005325672
c161e869d3 Daily arc lint --take KTFMT
Reviewed By: ivanmurashko

Differential Revision: D48553786

fbshipit-source-id: 269d46620ad34bd94a4df0d04ef3dfa5afbab613
2023-08-22 02:53:13 -07:00
Luke De Feo
4cc03ef4b2 Add litho framework events
Summary: Leverages the new connection listener inside the ui debugger to send framework events out of the Litho debug api and to the UIDebugger

Reviewed By: adityasharat

Differential Revision: D48350647

fbshipit-source-id: 2af48578b70bc50da43712f244f2bd208ad40988
2023-08-21 05:48:23 -07:00
David Vacca
76341a0215 Fix NoSuchMethodError when calling FbReactApplicationBaseSonarUtil.startSonarClient
Summary:
This diff is fixing a NoSuchMethodError when calling FbReactApplicationBaseSonarUtil.startSonarClient.

This is causing catalyst Android app to not start.

This was caused by D47468613, which changed the signature of the method

Reviewed By: cortinico

Differential Revision: D48275730

fbshipit-source-id: 4693c299dbd3b6a9ad58a1439bddd9e4bfb8bdf5
2023-08-14 09:54:54 -07:00
Luke De Feo
b30f7492cd Add connection listeners and framework events
Summary: Infra that will be used to capture litho framework events

Reviewed By: lblasa

Differential Revision: D47951601

fbshipit-source-id: 1dd756dc872d474f2872ff8cac1fd6aa3697e42b
2023-08-08 11:43:05 -07:00
Luke De Feo
1de033c157 Add bounds to fragment
Summary: Previously the bounds was 0, the trick is to steel the offset from the view and then use offsetchild zero so it doesnt get applied twice

Reviewed By: lblasa

Differential Revision: D47915115

fbshipit-source-id: ff771470dcf1720ca265fc9017ff0ea3b0bc1ca1
2023-07-31 10:53:03 -07:00
Luke De Feo
6b74f66ab4 Add parent id to decor view
Summary: This whole nested observer approach can be simplified massively, but for now we are just threading the parent id through so its set for observer roots too

Reviewed By: lblasa

Differential Revision: D47915504

fbshipit-source-id: 924f722f38bb202b42ea9ef6da15e685f6c75e02
2023-07-31 10:53:03 -07:00
Luke De Feo
413f85964b Send invisible as hidden attribute
Summary: This allows UIDebugger to draw them differently in tree and visualiser

Reviewed By: lblasa

Differential Revision: D47915505

fbshipit-source-id: a4d2ef9d653233e3ff24bc26cfe8017f9b51dd2b
2023-07-31 10:53:03 -07:00
Luke De Feo
60016e69f5 Remove Node id default impl
Summary: This is never identity hash code for declarative framework so this default impl is just a source of bugs, including this one.

Reviewed By: lblasa

Differential Revision: D47754625

fbshipit-source-id: 470aab084c82fa847f25116342021a79d52b7c67
2023-07-26 04:58:43 -07:00
Lorenzo Blasa
07292f837d Clear event handler after error or close
Summary:
Previous approach was a bit flawed as the `isOpen()` API returns true by the time close is called.

This was OK in the case of errors, as the open flag was set to false hence preventing us to report a close after the error. It is not OK on healthy disconnect situations as these events were not getting reported.

In this case, a better solution is just to clear the event handler after a close or error because in either case we are no longer interested in dispatching any other events to the handler.

Reviewed By: antonk52

Differential Revision: D47510883

fbshipit-source-id: 883a3f87f24f71fe44a624590a310fe2563cbd8a
2023-07-17 06:54:35 -07:00
Luke De Feo
20d7b57dbe Fix KState extraction
Summary:
The field changed from mStates to states breaking our reflection based code. Ideally I would like to just check if type == KStateContainer and access the field normally but the rest of the infrastructure expect to work on a java field.

Added tests to catch this sort of thing in the future. had to shift buck files around a bit to get it to work

Reviewed By: antonk52

Differential Revision: D46974357

fbshipit-source-id: 87a6f5883b33e4d1a7359df5987fc7ead7c19033
2023-07-03 12:19:26 -07:00
Lorenzo Blasa
e42db220ee Socket connect no longer synchronous and blocking
Summary:
Never really liked this code. Before this change, calls to connect were blocking.

Because of this, we had to make use of promises and a bit of really not that good-looking code.

So, this change makes connect non-blocking meaning that we make full use of our event handler.

These changes contain:
- CSR is not getting generated after each failed attempt.
- Connect is no longer blocking.
- Do not report events via the handler when explicitly disconnecting.

Reviewed By: jknoxville

Differential Revision: D46853228

fbshipit-source-id: 00e6a9c7c039a756175fe14982959e078d92bacb
2023-06-28 12:09:58 -07:00
Luke De Feo
35e2dd2e17 Use is connected flag to know to wrap bloks
Summary:
we need to wrap the bloks layout in a debug variet in order for flipper to work. See this diff for context D45605120

We are now using wether flipper is connected at all which is much more reliable.

Reviewed By: lblasa

Differential Revision: D46854921

fbshipit-source-id: 1b3baef2681ccce50fd452044cd3f740c256b0a9
2023-06-20 05:25:21 -07:00
Lorenzo Blasa
468b5510a8 New 'isConnected' API
Summary: Expose the newly created `isConnected` API to Android FlipperClient API.

Reviewed By: LukeDefeo

Differential Revision: D46841260

fbshipit-source-id: 1512e54d28779ef62423aa52727fed3a34d00333
2023-06-20 00:46:55 -07:00
Carmi Grushko
947f1932b5 Update ktfmt component on FBS:master
Differential Revision: D46802820

fbshipit-source-id: a2737658576bf86f431a7b355d853a529f6a2c34
2023-06-18 23:22:12 -07:00
Pascal Hartig
7a23d6ab20 Copy deprecation note (#4756)
Summary:
[android] Copy deprecation note
Ran the Kotlin migration process. They recommend we carry forwards these warnings.

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

Test Plan:
- CI

 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/flipper/pull/4756).
* https://github.com/facebook/flipper/issues/4759
* https://github.com/facebook/flipper/issues/4758
* https://github.com/facebook/flipper/issues/4757
* __->__ https://github.com/facebook/flipper/issues/4756
* https://github.com/facebook/flipper/issues/4755
* https://github.com/facebook/flipper/issues/4754
* https://github.com/facebook/flipper/issues/4753
* https://github.com/facebook/flipper/issues/4752
* https://github.com/facebook/flipper/issues/4751

Reviewed By: ivanmisuno

Differential Revision: D46068989

Pulled By: passy

fbshipit-source-id: 7011939d9a3970376348c5b03e2352719aff3948
2023-05-24 04:19:58 -07:00
Richard Zadorozny
03a5aaa3f7 Make sure FlipperSocketImpl always sets thread TrafficStats tag
Summary:
When looking at some of our logcats in logview, I noticed lots of StrictMode warnings related to a WebSocket not being tagged, and I figured out it was due to FlipperSocketImpl.

By making sure TrafficStats stats tag is set no matter if the SSL factory is used or not, it reduces the amount of StrictMode warnings we see.

Related diff: D38280819

Differential Revision: D46024367

fbshipit-source-id: 92a0bfcef8698a61ef9b27949a5bc0859e03448f
2023-05-19 17:41:14 -07:00
Nikita Lutsenko
b66bff3837 sonar | Replace global static variables within jni/sonar.cpp with local static.
Summary: Replacing global static varaibles with local static. No cost at startup time, and also fixes any potential static initialization order fiasco.

Differential Revision: D45900844

fbshipit-source-id: 4ff05cbefe2f0c00199f40b9127e28c355d1819e
2023-05-16 18:56:17 -07:00
Luke De Feo
23ebd8b865 Change logic for generating debug wrapper for nodes
Summary:
Previously we would only generate debug wrapper for render core layout result when uidebugger was currently connected.

This meant if you navigate to a bloks screen *before* having the ui debugger open at render time it would read ui debugger as disconnected since the ui debugger is not a background plugin. The result is the user would see the native nodes instead of the bound tree, it was extra confusing since the layout result was cached so going forward and back doesnt solve it.

The ideal solution would be to have a global flipper is connected on the client but this isnt available yet, lorenzo said he would work on it later.

As a work around we use the fact that the uidebugger has ever been connected in this session.

It can still be confusing since the initial load of a bloks screen migt not generate the debug nodes until you navigate to the plugin once. I will add a note to the docs so say that you need to have open the uidebugger once before nodes will appear

Reviewed By: mweststrate

Differential Revision: D45605120

fbshipit-source-id: 970943b9f8f98221b7fc5e20bb1caf18c2266474
2023-05-10 05:05:34 -07:00
Luke De Feo
70cdc9bedc Android start sending frame scan event instead of subtree update
Summary: Cosmetic change to make the events more inline with what they are

Reviewed By: lblasa

Differential Revision: D42999134

fbshipit-source-id: e026e38da7e50e8f5520271246f9627eb22e8965
2023-05-04 04:12:01 -07:00
Luke De Feo
98b94d62cf Add bloks integration infra + Layout result wrapper
Summary:
This adds the base infra for the UIDebugger bloks integration as well as an implementation for the Layout result wrapper for bloks. When theUIDebugger is connected we wrap the original layout result with a debug varient that delegates all methods to the original layout result but also provides access to the bloks model.

This allows the UIDebugger to inspect the Layout result and bloks model together

Reviewed By: pasqualeanatriello

Differential Revision: D43444444

fbshipit-source-id: ac531a0c7491c05db1d6f7671e3ab09c73c213b9
2023-05-03 07:51:29 -07:00
Lorenzo Blasa
8657bcba64 Report payload size
Summary: Android changes to send payload size

Reviewed By: passy

Differential Revision: D45121791

fbshipit-source-id: 2cdf8f7b8849bce06949d3f7db6bdc5674fe15b7
2023-04-21 04:09:23 -07:00
Luke De Feo
53aca9a661 Hidden attributes
Summary:
These are attributes that are:
1.  Not common across frameworks
2. Not in every node
3. Will not be visualised via inspectable attribute mechansism

Currently we will use them for bloks but they should be useful for other features down the road

Reviewed By: lblasa

Differential Revision: D45048025

fbshipit-source-id: c258d0a384a2b09abb642778e68da178899fa9eb
2023-04-18 08:01:50 -07:00
Luke De Feo
c2fc54057a Make metadata tags a map and rename to custom attributes
Summary: This will allow a lot more flexibility and will be essential for making bloks work

Reviewed By: lblasa

Differential Revision: D44871256

fbshipit-source-id: 59d9fdccea7b18406eac532080e80a69a251267b
2023-04-18 08:01:50 -07:00
Luke De Feo
eee74044ff Start sending parent id
Summary: Since subtree update is effectively a frame dump its a lot easier to send the parent ID. This will save having figure it out on the client which is somewhat expensive and is needed for bloks

Reviewed By: lblasa

Differential Revision: D45048023

fbshipit-source-id: 90c4888df063de0aa69c9b93c86d9891e30becbe
2023-04-18 08:01:50 -07:00
Razvan Racasanu
c3381a3c9f Add Flipper support for secondary processes
Summary: Allow callers to pass id, deviceName, processName, and packageName when initializing Flipper. Since these are used to create the connection id, callers can use these to configure Flipper to work for secondary processes.

Reviewed By: calebgomer

Differential Revision: D44719389

fbshipit-source-id: 3df6d47855c113f454f37031df32c4891626aa66
2023-04-07 12:58:52 -07:00
generatedunixname89002005232357
452154802f Revert D44566060: Multisect successfully blamed D44566060 for test or build failures
Summary:
This diff is reverting D44566060
D44566060: Add Flipper support for secondary processes in Messenger VR by rra has been identified to be causing the following test or build failures:

Tests affected:
- [//fbandroid/javatests/com/facebook/messenger:no_sonar_in_production - main](https://www.internalfb.com/intern/test/281474996792449/)

Here's the Multisect link:
https://www.internalfb.com/multisect/1809753
Here are the tasks that are relevant to this breakage:

We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it.

If you believe this diff has been generated in error you may Commandeer and Abandon it.

Reviewed By: passy

Differential Revision: D44682510

fbshipit-source-id: c0ae489bc5ae22c5339edd2c8988126b0adedd7f
2023-04-05 10:15:57 -07:00
Razvan Racasanu
2c12166b54 Add Flipper support for secondary processes in Messenger VR
Summary: Allow callers to pass id, deviceName, processName, and packageName when initializing Flipper. Since these are used to create the connection id, callers can use these to configure Flipper to work for secondary processes.

Reviewed By: passy

Differential Revision: D44566060

fbshipit-source-id: 605264c230956f4c9643c95c610ec40d736547ac
2023-04-04 11:25:23 -07:00
Lorenzo Blasa
8f9bf978e1 Ignore OverlayHandlerView as active child
Summary:
On foldable devices, there's an issue whereas the topmost root view is of type `OverlayHandlerView`.

This doesn't seem to be related in any way to the running app's UI. Or at least is not something of interest when debugging the running app's UI (for example, ig4a).

This change effectively ignores the `OverlayHandlerView` instance as active child and instead returns the next to last root view.

Reviewed By: LukeDefeo

Differential Revision: D44579223

fbshipit-source-id: cea52289c5ba1e6a96817232ac54725b8d2f48d9
2023-03-31 10:11:06 -07:00
Ruslan Shestopalyuk
aa6f04815b Add option to allow debugging Android services as well (#4631)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/4631

In React Native for VR we use `FlipperUtils.shouldEnableFlipper()` to determine whether Flipper should be enabled for the given app build.

The problem is that some of our apps are legitimately running as services (e.g. `com.oculus.explore:explore`), so the check added inside Flipper in D5126205 which only enables Flipper for "main application's process".

This diff adds an ability to relax this requirement (as we do want to do it for the RN VR applications)

Reviewed By: passy

Differential Revision: D44511667

fbshipit-source-id: 673912b204391799a9e8821b737681d1f44bd6a8
2023-03-30 04:17:43 -07:00
Lorenzo Blasa
76bfd67cd9 PerformanceStatsEvent
Summary: ^

Reviewed By: aigoncharov

Differential Revision: D44062826

fbshipit-source-id: 3f66411a8648e635b75dfea29a6256e64cfbf5d5
2023-03-16 07:35:44 -07:00
Luke De Feo
914b32c383 Add framework event infra
Summary:
Added infra for collecting events from UI frameworks.
1. Framework event metadata captures all the static metadata around the event. This allows to us to not send the same metadata in every event as well as populate the monitoring drop down immediately. This is sent in init since this information is static
2. Framework event itself is quite bare at the moment. It will have thread and more attributes in the future

The UIdebugger litho support ulitity has been simplified now there are 3 extension points.

Context renamed to UIDContext since it is referenced in app initialisers where the android context is also imported and it create a naming collision

Reviewed By: lblasa

Differential Revision: D42606933

fbshipit-source-id: a419f3fd424c533d586813004c40b68feafd9a2e
2023-03-01 08:49:49 -08:00
Fabio Carballo
fa74ebba68 Restore TimeMachine in Flipper
Summary:
The goal is to restore the *TimeMachine* functionality in Flipper while the new UI Debugger is working in a revamped version. This version was previously removed in D42573698 (b31f8c8755).

This time machine functionality will only be available for *LithoView* that are backed by a *ComponentTree*.

Below you can find a high-level overview of the current schema:

{F884011465}

Reviewed By: LukeDefeo, adityasharat

Differential Revision: D43574130

fbshipit-source-id: fe9d661e5fcce9655e70be4785652e7048dade54
2023-02-27 12:19:37 -08:00