Commit Graph

28 Commits

Author SHA1 Message Date
Anton Nikolaev
a4eb2a56d6 Option for "yarn start" and "yarn build" scripts to pre-install default plugin packages instead of bundling them
Summary:
Sorry for long diff! I can try to split it if necessary, but many changes here are 1-1 replacements / renames.

**Preambule**
Currently we bundle default plugins into the Flipper main bundle. This helps us to reduce bundle size, because of plugin dependencies re-use. E.g. if multiple plugins use "lodash" when they are bundled together, only one copy of "lodash" added. When they are bundled separately, the same dependency might be added to each of them. However as we're not going to include most of plugins into Flipper distributive anymore and going to rely on Marketplace instead, this bundling doesn't provide significant size benefits anymore. In addition to that, bundling makes it impossible to differentiate whether thrown errors are originated from Flipper core or one of its plugins.

Why don't we remove plugin bundling at all? Because for "dev mode" it actually quite useful. It makes dev build start much faster and also enables using of Fast Refresh for plugin development (fast refresh won't work for plugins loaded from disk).

**Changes**
This diff introduces new option "no-bundled-plugins" for "yarn start" and "yarn build" commands. For now, by default, we will continue bundling default plugins into the Flipper main bundle, but if this option provided then we will build each default plugin separately and include their packages into the Flipper distributive as "pre-installed" to be able to load them from disk even without access to Marketplace.

For "yarn start", we're adding symlinks to plugin folders in "static/defaultPlugins" and then they are loaded by Flipper. For "yarn build" we are dereferencing these symlinks to include physical files of plugins into folder "defaultPlugins" of the produced distributive. Folder "defaultPlugins" is excluded from asar, because loading of plugins from asar archive might introduce some unexpected issues depending on their implementation.

Reviewed By: mweststrate

Differential Revision: D28431838

fbshipit-source-id: f7757e9f5ba9183ed918d70252de3ce0e823177d
2021-05-18 08:08:30 -07:00
Pascal Hartig
9e7a455910 Mute port forwarding errors
Summary: Mentioned in the comment, these aren't actionable errors.

Reviewed By: jknoxville

Differential Revision: D27910465

fbshipit-source-id: 6f5e9d9d25edbb02648f3118c074e9f1986e3a86
2021-04-22 07:45:33 -07:00
Michel Weststrate
6a30899803 Kill onRegisterDevice
Summary: `onRegisterDevice` device abstraction was only used by the CrashReporterPlugin, and since with Sandy plugin lifecycles every plugin can do 'on-load' logic, we don't need it anymore.

Reviewed By: priteshrnandgaonkar

Differential Revision: D27046711

fbshipit-source-id: 16c567c60ed29a50017d525a2b707ee696a99e62
2021-03-16 15:03:48 -07:00
Pritesh Nandgaonkar
a2d559c8c0 Detect Physical iOS device without Xcode
Summary:
This diff adds the support of detecting physical device in Flipper even if the xcode is not installed and there is no cli tool installed.

See the demo.

Reviewed By: timur-valiev

Differential Revision: D26816588

fbshipit-source-id: 5f052998fcbe5c51385222d16df0e1855177b552
2021-03-05 11:36:20 -08:00
Pascal Hartig
390f27a137 Start bridge abstraction
Summary: This is just an early start of centralising some ad-hoc logic we've got all over the place right now. Memoised do-we-have-idb calls with concatenated shell invocations. This gives us the opportunity to do a bit of testing, too.

Reviewed By: mweststrate

Differential Revision: D26694863

fbshipit-source-id: cd2b9883f90397802bbaae6030f7cb3881c565c2
2021-03-02 09:53:19 -08:00
Pascal Hartig
43242557aa Remove listDevices
Summary: Appears to be unused.

Reviewed By: mweststrate

Differential Revision: D26753922

fbshipit-source-id: 7a21b8242e4c8d2428a286bc6ef63adafe74a78c
2021-03-02 09:53:18 -08:00
Michel Weststrate
224ec4d5d6 Fix device cleanup
Summary:
Fixes https://github.com/facebook/flipper/issues/1989

We had some self healing side effect that would destroy devices when registering a new device with the same serial, if they weren't yet. Redux isn't too happy about that, causing the attached crash.

Instead introduced a utility to destroy devices, and log an error if the device life cycle isn't respected by the device implementations, rather than crashing we will now just waste some memory.

Changelog: Fix a crash when disconnecting metro devices

Reviewed By: passy

Differential Revision: D26749214

fbshipit-source-id: 4c185ac521d44c1337fac8a9145440123b8b784c
2021-03-02 03:58:55 -08:00
Anton Nikolaev
fa3ff83595 Rename star/unstar actions to enable/disable/switch
Summary:
Renamed actions "star" and "unstar" everywhere to "enable", "disable" and "switch". The logic behind original "star" action changed significantly, so this rename just makes everything much clearer.

Please note that as a part of rename persisted state fields "userStarredPlugins" and "userStarredDevicePlugins" were renamed. I've added a "redux-persist" migration for seamless transition.

Reviewed By: passy

Differential Revision: D26606459

fbshipit-source-id: 83ad475f9b0231194701c40a2cdbda36f02c3d10
2021-02-24 05:30:57 -08:00
Anton Nikolaev
c0010bea4c Fix to avoid loading of disabled device plugins
Summary: There is a bug right now that even for disabled plugins we're loading them. In particular, this led to the Flipper freezes caused by Logs plugin even if it is disabled.

Reviewed By: passy

Differential Revision: D26503012

fbshipit-source-id: 2068626f4637ced44c457ee1b7ba7fffdcf5aa47
2021-02-18 04:00:21 -08:00
Pritesh Nandgaonkar
6d2206769c Fix the regex to allow xcode from non standard location (#1939)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1939

This diff fixes T84865014. We used to assume in our xcode cli check that xcode will be run from standard /Applications folder. But as mentioned in the above tasks, its not always true.

Reviewed By: passy

Differential Revision: D26484287

fbshipit-source-id: 32d343dece53576f99cbbb6d193138e803505935
2021-02-17 09:45:19 -08:00
Pascal Hartig
92f3ab8ff4 Improve error handling for iOSDevices
Summary:
Adding context everywhere as naked messages are hard to track down
and making common errors like missing Xcode license agreements
a warning + error popup instead.

Changelog: Reduce spamminess of iOS connection warnings

Reviewed By: mweststrate

Differential Revision: D26370235

fbshipit-source-id: b283d297479c2bf76a11b5a3f96a59fad70a4a67
2021-02-11 05:08:36 -08:00
Michel Weststrate
43c68c0e7c Separate the concepts of archived and disconnected devices
Summary:
Minor code cleanup to avoid future confusion:

- archived: a device that was imported from a Flipper trace, and only has persisted state
- (dis)connected: a real stateful device that might or might not have an active connection

Reviewed By: nikoant

Differential Revision: D26275459

fbshipit-source-id: eba554b37c39711e367c3795ff4456329a303c22
2021-02-09 04:16:26 -08:00
Michel Weststrate
7e1bf0f58b Preserve client state after disconnect
Summary:
This diff introduces support for keeping clients around after they have disconnected. This is a pretty important debugging improvement, that will allow inspecting a device / app after it crashed for example.

With this diff, the current client is just kept around until it connects again, instead of throwing clients immediately away if they disconnect. After this change, ArchivedClients will only be created by imports / exports, and no longer by disconnects. Initially I played with improving the creation of archived devices, by migrating all plugin state over from the original client to the archive, but I discovered that is very prone, as it would be a lot of pointer redistribution (plugins would point to a different client / device etc). While in contrast, disconnected clients is already an existing concept in Flipper, so reusing that keeps all the changes relatively simple.

Note that we could potentially still reuse old clients around after reconnected, but it would become much harder to reason about how plugins would behave if they missed updates for a while, so throwing away the device / clients and starting with a fresh slate sounds safer. So I figured that chance to be too risky for now, but would probably be good follow up work.

Issues with import / export, UX, and making calls to to a disconnected client will be addressed in follow up diffs

Changelog: Clients will retain their state after being disconnected, until they reconnect again

Reviewed By: nikoant

Differential Revision: D26224677

fbshipit-source-id: feb9d241df2304341c2847fe7fd751ac54c045f6
2021-02-09 04:16:24 -08:00
Michel Weststrate
c43049d881 Preserve device state after disconnect
Summary:
This diff stack introduces support for keeping devices and clients around after they have disconnected. This is a pretty important debugging improvement, that will allow inspecting a device / app after it crashed for example.

This feature existed partially before, but only supported Android, and only support plugins with persisted state; as it replace the current device with an archived version of the same device. In practice this didn't work really well, as most plugins would not be available, and all non-persisted state would be lost.

This diff makes sure we can keep devices around after disconnecting, the next one will keep the clients around as well. And explain some code choices in more detail.

Note that `Device.isArchived` was an overloaded term before, and even more now (both representing imported and disconnected devices), will address that in a later diff.

https://github.com/facebook/flipper/issues/1460
https://github.com/facebook/flipper/issues/812
https://github.com/facebook/flipper/issues/1487

Changelog: iOS and Android devices will preserve their state after being disconnected

Reviewed By: nikoant

Differential Revision: D26224310

fbshipit-source-id: 7dfc93c2a109a51c2880ec212a00463bc8d32041
2021-02-09 04:16:24 -08:00
Anton Nikolaev
8ce69975a5 Re-enable asar and unpack PortForwardingMacApp
Summary: Enabled asar packaging for Flipper resources, and set PortForwardingMacApp as unpacked from it, because it is launched as external app.

Reviewed By: passy

Differential Revision: D26006771

fbshipit-source-id: 91c8401a469a390144bf9867996a66d754ea90e6
2021-01-22 08:21:47 -08:00
John Knox
41c7e023a9 Enable limited use of iOS devices on non Mac devices
Summary:
Context: https://fb.workplace.com/groups/flippersupport/permalink/1005193786627946/

I believe we can land this without knowing that it works, because iOS support is still disabled by default for non mac devices - you have to enable it in settings to switch it on.

Reviewed By: passy

Differential Revision: D24893757

fbshipit-source-id: c9db515a7807c94a0d5e509017dd4e1796d24f6d
2020-11-17 04:03:43 -08:00
Michel Weststrate
dcdec2608e Start simulator app if not already started
Summary:
Before this change, launching a simulator would ony show the simulator if the simulator process itself was already running. This makes sure that opening a simulator also works from a closed state

Changelog: Automatically start an iOS simulator to launch a device when none is running yet

Reviewed By: nikoant

Differential Revision: D24919363

fbshipit-source-id: 45039330710cf81aa73222967d667964bb01f42a
2020-11-12 16:32:57 -08:00
Michel Weststrate
17baa3084c Introduce emulatur launch dialog
Summary:
Changelog: Flipper can now launch iOS simulators by using `File > Launch Emulator...`

In the Sandy designs the device selector dropdown no longer shows the option to launch an emulator. So added a button to app inspect and the main menu instead.

I found it always a bit funny that we can launch android emulators, but not iOS emulators. Turns out that launching them is actually not very complex, so added capabilities to launch ios emulators

Reviewed By: jknoxville

Differential Revision: D24021737

fbshipit-source-id: c106cc2246921e008f9c808ebb811d8e333aa93b
2020-10-01 05:35:11 -07:00
Michel Weststrate
81eb09e7b0 Unify error notifications (#1483)
Summary:
Note: this is to be stacked upon https://github.com/facebook/flipper/pull/1479

Note: this PR will probably not succeed against FB internal flipper, as I'm pretty sure there are more call sites that need to be updated. So consider this WIP

Currently connection errors are managed in the connection reducers, and are displayed through their own means, the error bar. Showing console.errors is also hooked up to this mechanism in FB internal flipper, but not at all in the OSS version, which means that some connection errors are never shown to the user.

Besides that there is a notification system that is used by for example the crash reporter and plugin updater.

Having effectively (at least) two notifications mechanisms is confusing and error prone. This PR unifies both approaches, and rather than having the connection reducer manage it's own errors, it leverages the more generic notifications reducer. Since, in the previous PR, console errors and warnings have become user facing (even in OSS and production builds, which wasn't the case before), there is no need anymore for a separate error bar.

I left the notifications mechanism itself as-is, but as discussed in the Sandy project the notification screen will probably be overhauled, and the system wide notifications will become in-app notifications.

## Changelog

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

Test Plan: Only updated the unit tests at this point. Manual tests still need to be done.

Reviewed By: passy

Differential Revision: D23220896

Pulled By: mweststrate

fbshipit-source-id: 8ea37cf69ce9605dc232ca90afe9e2f70da26652
2020-08-21 10:08:21 -07:00
John Knox
d423afd75d Fix high pkd CPU usage issue
Summary:
Running `instruments -s devices` causes the `pkd` process in catalina to spike to ~100% for a few seconds.

Flipper runs this command every 3 seconds to poll for devices.
This switches it to use `idb list-targets` instead which is much more performant.

Currently switched off in the open-source version while we make sure it's working well. If you set the GK value 'flipper_use_idb_to_list_devices' to true, then you'll get the new behaviour.

Reviewed By: passy

Differential Revision: D23102067

fbshipit-source-id: 9e17155d938a4fe326e082511f747444e4b533a2
2020-08-13 03:48:09 -07:00
Michel Weststrate
9c202a4a10 Introduce menu entry support
Summary:
[interesting] since it shows how Flipper APIs are exposed through sandy. However, the next diff is a much simpler example of that

This diff adds support for adding menu entries for sandy plugin (renamed keyboard actions to menus, as it always creates a menu entry, but not necessarily a keyboard shortcut)

```

  client.addMenuEntry(
    // custom entry
    {
      label: 'Reset Selection',
      topLevelMenu: 'Edit',
      handler: () => {
        selectedID.set(null);
      },
    },
    // based on built-in action (sets standard label, shortcut)
    {
      action: 'createPaste',
      handler: () => {
        console.log('creating paste');
      },
    },
  );
```

Most of this diff is introducing the concept of FlipperUtils, a set of static Flipper methods (not related to a device or client) that can be used from Sandy. This will for example be used to implement things as `createPaste` as well

Reviewed By: nikoant

Differential Revision: D22766990

fbshipit-source-id: ce90af3b700e6c3d9a779a3bab4673ba356f3933
2020-08-04 07:47:14 -07:00
Michel Weststrate
d538b66088 Cleaned up deviceType enum
Summary:
The device type enum was mixing two different concepts (emulator vs physical) and (archived vs not), and we already have a separate `isArchived` field. So cleaned this up to not leak it into sandy.

If anybody can think of any unforeseen consequences of this, lemme know :)

Reviewed By: jknoxville

Differential Revision: D22763506

fbshipit-source-id: bd2f7dbd1d2d2e6942ba7c6ddd8dc91ee34d591d
2020-08-04 07:47:13 -07:00
John Knox
21a926232e Add idb check to doctor
Summary:
Adds a check for idb to flipper-doctor.

This depends on the flipper settings, to know where to look for idb, so I've made it so you can pass settings into the doctor when running it. When run from the command line, you don't get the settings. This is because settings loading currently depends on redux so I haven't extracted it into its own package.

Not that this will notify ALL open source iOS users with a doctor warning because they don't have idb installed. The error message says you can disable it in settings, which will silence this warning.

CHANGELOG: The open source version now works with physical iOS devices.

Reviewed By: passy

Differential Revision: D21883086

fbshipit-source-id: f28c43487e88a6c07ef3cc3da2764026726c9f18
2020-06-09 06:56:09 -07:00
Michel Weststrate
b94e426261 Make iOS device detection faster
Summary:
I noticed that Android device detection is _much_ faster than iOS, so I tried to optimize it a bit

1. Removed a test run on `instruments -s`. That command is really slow (easily 5 secs), and the check has become redundant since Doctor already does a similar check
2. When querying for devices, it tries to fetch emulated and physical devices in parallel, but only processes the results after both have finished. However, finding simulators is almost instant, while querying the physical devices takes ~5 seconds ore more. So in this diff we process the found devices till in parallel, rather than waiting until both have arrived

This diff reduces the time until the ios simulator + FB app is detected from 28 to 4 seconds on my machine.

Changelog: Improved the startup sequence for emulated iOS devices, so that devices and apps connect a lot faster after starting Flipper

Reviewed By: jknoxville

Differential Revision: D21907597

fbshipit-source-id: 73edf0b04c4ad8367e04557e33f4c0d9e9bcd710
2020-06-08 03:44:51 -07:00
John Knox
ab84bd563a Enable physical iOS devices in open source
Summary:
The last piece of the puzzle to get this working.

Now if a user has iOS development enabled in Flipper settings, and has XCode installed, we'll run the PortForwardingMacApp processes required to interact with iOS devices.

It's not great the way it starts the processes without any error checking, but since that's the way it currently works, I'm leaving it as it is for now.

Reviewed By: mweststrate

Differential Revision: D21881041

fbshipit-source-id: 1d1fdb7e0621cff88408bb707d768bb5c6bea0cc
2020-06-04 08:15:30 -07:00
John Knox
5723553fba Open-source idb interaction code
Summary:
I've outlined the tasks required to get iOS device support working for open source users [here](https://github.com/facebook/flipper/issues/262).

This is the first step. It publishes the same code we use internally to GitHub, but in a state where it is only "available" for non-public builds. This will not change any behavior, but means that together with the community, we can start adapting it to suit everyone, and then eventually flip "available" to true for everyone.

Reviewed By: passy

Differential Revision: D21740193

fbshipit-source-id: 586c79ad850f67da330c10a007605ff25a187544
2020-05-29 06:04:39 -07:00
Pascal Hartig
fc9ed65762 prettier 2
Summary:
Quick notes:

- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.

Close https://github.com/facebook/flipper/pull/915

Reviewed By: jknoxville

Differential Revision: D20594929

fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
2020-03-24 09:38:11 -07:00
Anton Nikolaev
863f89351e Yarn workspaces
Summary:
1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code
2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later.

Reviewed By: jknoxville

Differential Revision: D20535782

fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1
2020-03-20 13:37:41 -07:00