Commit Graph

26 Commits

Author SHA1 Message Date
Michel Weststrate
d2a2e2ab75 Introduce async message queuing
Summary:
This diff introduces the logic for queueing incoming messages rather then directly processing them you are behind the `flipper_event_queue` GK.

The reason the queue processing is a bit complicated is to make the queue can be processed non-blocking, can be cancelled, and is safe to concurrency issues.
The idea here is that the queue is processed when we switch to a plugin, report it's progress, and abort the process when switching to another plugin without loosing any work.

This diff does not include
[x] updates to the UI (**SO DON"T LAND IN ISOLATION**)
[x] metrics to see the effect

The effect of the changes can be seen when profiling the application, before this change there are very regular CPU spikes (see the small yellow bar on the top):

https://pxl.cl/TQtl

These go away when the events are no longer processed
https://pxl.cl/TQtp

Reviewed By: nikoant

Differential Revision: D19095564

fbshipit-source-id: 0b8c3421acc4a4f240bf2aab5c1743132f69aa6e
2020-01-02 07:14:12 -08:00
Michel Weststrate
91d5b95341 make it easier to test plugin logic
Summary:
This diff will make it easier to test a plugin in a "fully loaded" Flipper state. This makes it possible to test all the wiring of flipper, rather than the individual reducers.

This is in preparation of processing the message queue async.

Reviewed By: passy

Differential Revision: D19140879

fbshipit-source-id: 5a333abe9c7a4d0c33d1d06a105cd094cb8fc19f
2019-12-17 06:07:35 -08:00
Michel Weststrate
5429d1f235 Make it possible to generate regression tests for Flipper plugins
Summary:
This Pull request makes it possible to automatically generate regression tests for plugins. The idea here is to record all incoming states for a specific plugin, the start state of the plugin, and the enstate of the plugin.

By replaying the same events in a test, the same plugin should result in the same end state. This will make it easy to test regressions and refactorings on real life scenarios. Execution time is recorded as well.

The API's are exposed as

- `flipperStartPluginRecording()`
- `flipperStopPluginRecording()`

This process generates both a data snapshot and unit test.

Reviewed By: passy

Differential Revision: D18907455

fbshipit-source-id: 923f814f534ccfa6aa2ff2bfa2f80bee41a1c182
2019-12-11 05:53:22 -08:00
John Knox
1a389202ca Change client to not produce plugin keys manually
Summary: I **think** this is the last part of the codebase doing manipulation of strings to produce plugin keys etc.

Reviewed By: passy

Differential Revision: D18831990

fbshipit-source-id: db449d78230adbca66e78f041381a34d9b249a45
2019-12-05 11:45:37 -08:00
Michel Weststrate
7f916f8a7b Gather plugin stats to improve performance
Summary: This diff makes it possible to gather stats of plugin usage, and print them from the console by issuing `window.flipperPrintPluginBackgroundStats()`.

Reviewed By: jknoxville

Differential Revision: D18811590

fbshipit-source-id: 4219923f7fd90187c7ec50a9aa68d7b817e3db8f
2019-12-05 09:30:33 -08:00
Pascal Hartig
0a7c57f5a0 Back out "Back out "[flipper][js] JS apps support 1/n""
Summary:
Original commit changeset: ff84080d43fa

This re-adds JS client support. The original version had a small bug that inadvertantly wrapped support for Android emulators in the dropdown in a GK that was only meant to cover JS clients. This is addressed here.

Reviewed By: timur-valiev

Differential Revision: D18707485

fbshipit-source-id: ceea8e279a21111f96073f8b784e852f6313e2a4
2019-11-26 09:37:57 -08:00
John Knox
2fd6301876 Back out "JS apps support 1/n"
Summary:
Original commit changeset: 56d1ca1a60ed

This broke Android support in some instances. We haven't had a chance to investigate this yet, but this should cleanly reapply, so we can figure out what happened after the release.

Reviewed By: cekkaewnumchai

Differential Revision: D18688590

fbshipit-source-id: ff84080d43fa481cc8c8c669a76aed15d0f8aa56
2019-11-26 05:30:34 -08:00
Timur Valiev
c685493db0 JS apps support 1/n
Summary:
### Connecting Flipper with JS apps by using electron's BrowserWindow and IPC

1. UI: there is a menu item in Devices tab which opens JS Emulator Launcher Sheet. Here we can configure URL to open and initial size of the window.
2. BrowserWindow, preloaded js: there is SupportJSClientPreload.js which initialize communication between flipper and app via electron's ipc
3. On flipper's side there is src/utils/js-client/serverUtils.tsx which contains most of JS emulator related code
4. Extracting of FlipperClientConnection: since we don't use RScocket to communicate with JS app I extracted needed methods to FlipperClientConnection (located in Client) and partly implemented them in JSClientFlipperConnection (requestResponse is just send a message now, doesn't return actual result)

Reviewed By: jknoxville

Differential Revision: D18572882

fbshipit-source-id: 56d1ca1a60ed2e51329b917021a09382cbb1ceec
2019-11-22 03:11:29 -08:00
Michel Weststrate
3cee927674 Introduce favorite plugins
Summary: This diff lands improved sidebar navigation. The old functionality to order plugins based on last-recently-used, and cropping at 5 items has been removed. Instead, items can be starred and their position will be fixed. Together with the app switcher introduced this should lead to a cleaner, stabler, and more customizable UI.

Reviewed By: jknoxville

Differential Revision: D18299401

fbshipit-source-id: 29b7eb3a4130933c637f7c81834558bf738d5bf0
2019-11-05 09:14:46 -08:00
Andres Suarez
0675dd924d Tidy up Flipper license headers [1/2]
Reviewed By: passy

Differential Revision: D17863711

fbshipit-source-id: 259dc77826fb803ff1b88c88529d7f679d3b74d8
2019-10-11 13:46:45 -07:00
Pritesh Nandgaonkar
e0e0a8f916 Add device argument in the constructor of Client
Summary: Property `device` on Clients for archived device never resolve. As it gets resolved when `addConnection` is called which happens for real non-offline devices. To get around this, I have added an argument to the constructor of the Client, as for offline case we can construct the device before client and can pass it as an argument.

Reviewed By: jknoxville

Differential Revision: D17831261

fbshipit-source-id: a14fb0b65343cccac731077e983026388611d323
2019-10-10 08:22:52 -07:00
Chaiwat Ekkaewnumchai
2239ca65a5 Fix Android Connection Swap Issue (Server Side)
Summary:
- Take device id retrieved by matching CSR to the given CSR destination
  - Otherwise, use the previous way

Note:
- Backward compatibility will be fixed next diff

Reviewed By: jknoxville

Differential Revision: D17346422

fbshipit-source-id: 59b2fb9849373db1ba930dde702194c5fb201678
2019-09-16 05:33:19 -07:00
Pascal Hartig
cbbe32b9b9 Remove FlowFixMe's from TypeScript
Summary: This diff was a joy to draft.

Reviewed By: jknoxville

Differential Revision: D17344676

fbshipit-source-id: 0694d0393fa243edef61408ecfee92912fbbfa32
2019-09-12 10:20:08 -07:00
Pascal Hartig
f48fe21eaa Make client.device fulfill type constraints
Summary:
This is an interesting invariant that TS caught here. We
expect `getDevice()` to always return a device but it
cannot because it's set lazily. John Knox suggested we instead
set up a promise in the constructor and resolve it instead of
overriding the stateful promise later.

Reviewed By: jknoxville

Differential Revision: D17313468

fbshipit-source-id: 8fd75f2720546abf67beead23db56216f1a5e0df
2019-09-11 05:38:19 -07:00
Pascal Hartig
c2e2915471 Make Client strict
Summary:
Could use a closer look. *Shouldn't* change semantics,
but there are some assumptions baked into the code
which I don't fully grasp.

Reviewed By: jknoxville

Differential Revision: D17282310

fbshipit-source-id: af8e6bcd188bd12180a7b2eeafee7ced4f44d1aa
2019-09-10 10:33:24 -07:00
Pritesh Nandgaonkar
a492ddaae8 Strictify server.tsx
Summary: As per title

Reviewed By: danielbuechele

Differential Revision: D17267564

fbshipit-source-id: d99fe62cc22fa3664d5aa6d4770d864fdd212ef4
2019-09-10 07:47:16 -07:00
Daniel Büchele
5868946818 certificate provider
Summary: _typescript_

Reviewed By: passy

Differential Revision: D17096517

fbshipit-source-id: a6e69e8b9a82fe76bb1de51a3a93182f35f40b3f
2019-08-28 20:34:59 -07:00
Chaiwat Ekkaewnumchai
f9fa80d93b Expand/Collapse Plugin Sidebar v1
Summary:
* Change the way to determine recently used plugins
* Show all plugins if there are just a few hidden plugins
  * Not all of plugins in client list can be showed, so checking happens when rendering
* Add action to clear the history internally (for testing) (not sure if needed)

Reviewed By: danielbuechele

Differential Revision: D16965302

fbshipit-source-id: 6efeedac8c0fad7e89a96e7fc5ba9101d3516fe7
2019-08-23 04:42:06 -07:00
Chaiwat Ekkaewnumchai
ea7578aa16 Expand/Collapse Sidebar V0
Summary:
- Show all or show 5 LRU plugins
- Update when close/reopen app, collapse sidebar, or expand sidebar

Reviewed By: danielbuechele

Differential Revision: D16917950

fbshipit-source-id: 1e7edc86945162ea14e1cdaa89aa47d3defa4c7d
2019-08-21 08:50:34 -07:00
Chaiwat Ekkaewnumchai
007a29805a Setting up Persist Storage for LRU Plugins
Summary:
- Change policy to show plugins to LRU (least recently used)
- Add persist storage to store LRU plugins

Reviewed By: danielbuechele

Differential Revision: D16917951

fbshipit-source-id: 8ea7b2f15e06db51209953818f465a05e24c38c4
2019-08-21 08:50:34 -07:00
Chaiwat Ekkaewnumchai
afd7634fd6 Add Button to Expand or Collapse Left Panel
Summary:
- Add `show more` and `show less` button to expand and collapse
- The element to show depends on its usage rank from Flipper dashboard (manually copied)

Reviewed By: danielbuechele

Differential Revision: D16917952

fbshipit-source-id: fc37d5c640be33794694e302341fa08849b8f97f
2019-08-21 08:50:33 -07:00
Daniel Büchele
0ebacecaf6 TableNativePlugin
Summary: _typescript_

Reviewed By: priteshrnandgaonkar

Differential Revision: D16828096

fbshipit-source-id: 5850ac4dbf120d2e6b38761701b44d20565d00e7
2019-08-20 04:09:31 -07:00
Pascal Hartig
fcf99fda4b Migrate is{Headless,Production}
Summary: _typescript_

Reviewed By: jknoxville

Differential Revision: D16711115

fbshipit-source-id: 174e1d3057182c35a6e3493612ddcb3d6ba1ee54
2019-08-12 03:53:14 -07:00
Pritesh Nandgaonkar
47a55b0f26 Migrate BaseDevice from js to tsx
Summary: As per the title

Reviewed By: passy

Differential Revision: D16687261

fbshipit-source-id: a9d85424fb0a08fada7edd0355c356907518d366
2019-08-09 06:56:54 -07:00
John Knox
3bfb7faf0a Convert plugin.js to plugin.tsx
Summary:
* Deletes plugin.js
* Adds plugin.tsx
* Adds plugin flow-typed module that has the old flow types

Reviewed By: passy

Differential Revision: D16668067

fbshipit-source-id: b2f0ce47c4cf7125b4e352821e921b97675d12a9
2019-08-08 12:06:11 -07:00
Daniel Büchele
5f53087c7e client server
Summary: Migrating Server, Client and UninitializedClient to TypeScript

Reviewed By: passy

Differential Revision: D16687855

fbshipit-source-id: 402e4dbcd5d283d3e280d4d8b312662829457886
2019-08-08 11:00:38 -07:00