Commit Graph
153 Commits
Author SHA1 Message Date
JuanandGitHub 2bb87d09ca React DevTools 4.20.0 -> 4.20.1 (#22583) 2021-10-19 10:55:39 -04:00
JuanandGitHub e8b35bff63 React DevTools 4.19.2 -> 4.20.2 (#22569) 2021-10-15 12:50:17 -04:00
Gabriel TrompizandGitHub 101be40f95 Reattachment of the splash page event listeners (#22558) (#22560) 2021-10-15 09:16:43 -04:00
JuanandGitHub 415d45dbba Prevent errors/crashing when multiple installs of DevTools are present (#22517)
## Summary

This commit is a proposal for handling duplicate installation of DevTools, in particular scoped to duplicates such as a dev build or the internal versions of DevTools installed alongside the Chrome Web Store extension.

Specifically, this commit makes it so when another instance of the DevTools extension is installed alongside the extension installed from the Chrome Web Store, we don't produce a stream of errors or crash Chrome, which is what would usually happen in this case. 


### Detecting Duplicate Installations

- First, we check what type of installation the extension is: from the Chrome Web Store, the internal build of the extension, or a local development build.
- If the extension is from the **Chrome Web Store**:
  - During initialization, we first check if the internal or local builds of the extension have already been installed and are enabled. To do this, we send a [cross-extension message](https://developer.chrome.com/docs/extensions/mv3/messaging/#external) to the internal and local builds of the extension using their extension IDs.  
    - We can do this because the extension ID for the internal build (and for the Chrome Web Store) is a stable ID.
    - For the local build, at build time we hardcode a [`key` in the `manifest.json`](https://developer.chrome.com/docs/extensions/mv2/manifest/key/) which allows us to have a stable ID even for local builds.
  - If we detect that the internal or local extensions are already installed, then we skip initializing the current extension altogether so as to not conflict with the other versions. This means we don't initialize the frontend or the backend at all.
- If the extension is the **Internal Build**:
  - During initialization, we first check if the local builds of the extension has already been installed and is enabled. To do this, we send a [cross-extension message](https://developer.chrome.com/docs/extensions/mv3/messaging/#external) to the local build of the extension using its extension ID.  
    - We can do this for the local build because at build time we hardcode a [`key` in the `manifest.json`](https://developer.chrome.com/docs/extensions/mv2/manifest/key/) which allows us to have a stable ID even for local builds.
  - If we detect that the local extension is already installed, then we skip initializing the current extension altogether so as to not conflict with the that  version. This means we don't initialize the frontend or the backend at all.
- If the extension is a **Local Dev Build**:
  - Since other extensions check for the existence of this extension and disable themselves if they detect it, we don't need any special handling during initialization and assume that there are no duplicate extensions. This means that we will generally prefer keeping this extension enabled.

This behavior means that the order of priority for keeping an extension enabled is the following:

1. Local build
2. Internal build
3. Public build


### Preventing duplicate backend initialization

Note that the backend is injected and initialized by the content script listening to a message posted to the inspected window (via `postMessage`). Since the content script will be injected twice, once each by each instance of the extension, even if we initialize the extension once, both content scripts would still receive the single message posted from the single frontend, and it would then still inject and initialize the backend twice. 

In order to prevent this, we also add the extension ID to the message for injecting the backend. That way each content script can check if the message comes from its own extension, and if not it can ignore the message and avoid double injecting the backend.
  
### Other approaches

- I considered using the [`chrome.management`](https://developer.chrome.com/docs/extensions/reference/management/) API generally to detect other installations, but that requires adding additional permissions to our production extension, which didn't seem ideal.
- I also considered a few options of writing a special flag to the inspected window and checking for it before initializing the extension. However, it's hard to avoid race conditions in that case, and it seemed more reliable to check specifically for the WebStore extension, which is realistically where we would encounter the overlap.
  
### Rollout

- This commit needs to be published and rolled out to the Chrome Web Store first.
- After this commit is published to the Chrome Web Store, any duplicate instances of the extension that are built and installed after this commit will no longer conflict with the Chrome Web Store version.
  
### Next Steps

- In a subsequent PR, I will extend this code to show a warning when duplicate extensions have been detected.

Part of #22486

## How did you test this change?

### Basic Testing

- yarn flow
- yarn test
- yarn test-build-devtools

### Double installation testing

Testing double-installed extensions for this commit is tricky because we are relying on the extension ID of the internal and Chrome Web Store extensions, but we obviously can't actually test the Web Store version (since we can't modify the already published version).

In order to simulate duplicate extensions installed, I did the following process:

- Built separate extensions where I hardcoded a constant for whether the extension is internal or public (e.g. `EXTENSION_INSTALLATION_TYPE = 'internal'`). Then I installed these built extensions corresponding to the "internal" and "Web Store" builds.
- Build and run the regular development extension (with `yarn build:chrome:dev && yarn test:chrome`), using the extension IDs of the previously built extensions as the "internal" and "public" extension IDs.

With this set up in place, I tested the following on pages both with and without React:

- When only the local extension enabled, DevTools works normally.
- When only the "internal" extension enabled, DevTools works normally.
- When only the "public" extension enabled, DevTools works normally.
- When "internal" and "public" extensions are installed, "public" extension is disabled and "internal" extension works normally.
- When the local extension runs alongside the other extensions, other extensions disable themselves and local build works normally.
- When we can't recognize what type of build the extension corresponds to, we show an error.
- When all 3 extensions are installed and enabled in all different combinations, DevTools no longer produces errors or crashes Chrome, and works normally.
2021-10-14 17:15:31 -04:00
Gabriel TrompizandGitHub 18ec2f8890 Allow to use the Profiler when no client is connected in standalone DevTools (#22551) 2021-10-14 08:31:45 -04:00
Brian Vaughn 322de665f8 React DevTools 4.19.1 -> 4.19.2 2021-10-08 13:51:25 -04:00
Brian VaughnandGitHub bedaa94843 React DevTools 4.19.0 -> 4.19.1 (#22480) 2021-10-01 11:50:05 -04:00
Luna RuanandGitHub ec38aa815a React DevTools 4.18.0 -> 4.19.0 (#22461) 2021-09-29 12:06:13 -04:00
38elementsandGitHub 03d4d78443 Fix links in packages/react-devtools/README.md (#22356) 2021-09-20 15:10:29 -04:00
BIKI DASandGitHub ee814ff109 react-devtools\OVERVIEW.md --> fixed typos (#22372) 2021-09-20 15:09:37 -04:00
JuanandGitHub 2cea2a653d [DevTools] Enable hook names in standalone app (#22320) 2021-09-17 10:21:54 -04:00
Luna RuanandGitHub 605e66f5f4 [DevTools] Add React Devtools Extension Startup and File Structure to OVERVIEW.md (#22283) 2021-09-09 15:58:27 -07:00
Kausik S SandGitHub f17d6e52c7 Typo fixed (#22171) 2021-09-06 20:05:15 +01:00
Luna RuanandGitHub 7bea34f930 React DevTools 4.17.0 -> 4.18.0 (#22234) 2021-09-01 13:39:36 -07:00
Brian Vaughn 58f529ba02 React DevTools 4.16.0 -> 4.17.0 2021-08-24 11:12:42 -07:00
Brian VaughnandGitHub e4043a092c Automated DevTools release process (#22161) 2021-08-24 14:05:50 -04:00
Luna RuanandGitHub 7556f8b2f3 DevTools 4.15.0 -> 4.16.0 (#22104) 2021-08-16 14:55:47 -07:00
Brian VaughnandGitHub a9efcf48fb Updated DevTools CHANGELOG
Fixed header typo
2021-08-12 11:03:33 -04:00
Brian VaughnandGitHub a52f89c238 Added Scheduling Profiler notes and videos to the DevTools CHANGELOG 2021-08-12 11:02:30 -04:00
Brian VaughnandGitHub 8f9292c379 Add script to generate DevTools changelog text (#22077) 2021-08-12 10:43:56 -04:00
Brian VaughnandGitHub ea6a4314fb Added taneliang and kartikcho to scheduling profiler credits 2021-08-11 17:48:37 -04:00
JuanandGitHub 04c656936a DevTools 4.14.0 -> 4.15.0 2021-08-11 16:47:20 -04:00
65434875df Some remaining instances of master to main (#21982)
Co-authored-by: Shubham Pandey <[email protected]>
2021-07-30 08:56:55 -04:00
Brian VaughnandGitHub 0b23918b67 Added testing instructions to devtools contributing guide 2021-07-28 19:05:01 -04:00
Christian SchulzeandGitHub e2795e49d6 react-devtools: set icon on macos (#21908) 2021-07-19 10:26:41 -04:00
Brian Vaughn d60219b7f6 DevTools 4.13.5 -> 4.14.0 2021-07-16 00:25:01 -04:00
Brian VaughnandGitHub ef6779554a Update CONTRIBUTING.md 2021-07-08 17:38:59 -04:00
Brian VaughnandGitHub 6f1926091d Update CONTRIBUTING.md 2021-07-08 14:37:13 -04:00
Brian VaughnandGitHub 6b71efe2bc Update CONTRIBUTING.md 2021-07-08 14:28:53 -04:00
Brian Vaughn 39df730d4f Added DevTools CONTRIBUTING guide 2021-07-08 14:11:30 -04:00
Brian VaughnandGitHub 78f9773c62 Updated scripts and config to replace "master" with "main" branch (#21768) 2021-06-29 14:26:24 -04:00
Brian Vaughn 8ea654acd9 DevTools 4.13.4 -> 4.13.5 2021-05-25 15:18:47 -04:00
Brian Vaughn 850e661ea7 DevTools: Add 4.13.4 changelog 2021-05-20 17:00:17 -04:00
Brian Vaughn 7e9ccdc1c0 DevTools: Add 4.10.4 to CHANGELOG 2021-05-20 16:31:18 -04:00
Brian Vaughn 79b229fbc8 DevTools 4.13.3 -> 4.13.4 2021-05-20 11:24:30 -04:00
Brian Vaughn fa8f73c1d6 Updated DevTools CHANGELOG for 4.13.3 release 2021-05-19 10:59:32 -04:00
Brian VaughnandGitHub fc7ed12d54 Account for another DevTools + Fast Refresh edge case (#21523)
DevTools now 'untrack' Fibers (cleans up the ID-to-Fiber mapping) after a slight delay in order to support a Fast Refresh edge case:
1. Component type is updated and Fast Refresh schedules an update+remount.
2. flushPendingErrorsAndWarningsAfterDelay() runs, sees the old Fiber is no longer mounted (it's been disconnected by Fast Refresh), and calls untrackFiberID() to clear it from the Map.
3. React flushes pending passive effects before it runs the next render, which logs an error or warning, which causes a new ID to be generated for this Fiber.
4. DevTools now tries to unmount the old Component with the new ID.

The underlying problem here is the premature clearing of the Fiber ID, but DevTools has no way to detect that a given Fiber has been scheduled for Fast Refresh. (The '_debugNeedsRemount' flag won't necessarily be set.)

The best we can do is to delay untracking by a small amount, and give React time to process the Fast Refresh delay.
2021-05-18 22:44:29 -04:00
Brian Vaughn 26f6d06aa0 Added React entry-points change to DevTools changelog 2021-05-18 13:25:29 -04:00
Brian Vaughn 8fdba3b1be Preparing DevTools 4.13.2 -> 4.13.3 for release 2021-05-18 13:23:06 -04:00
Brian Vaughn e5aeab0276 DevTools 4.13.1 -> 4.13.2 2021-05-07 08:52:02 -04:00
Brian Vaughn 4bfee83725 Prepare DevTools 4.13.1 release 2021-05-04 22:35:30 -04:00
Brian VaughnandGitHub f4b88cd77b Preparing DevTools 4.12.4 -> 4.13.0 release (#21378) 2021-04-28 12:36:24 -04:00
Brian Vaughn 83ba9bc840 Updated DevTools CHANGELOG for 4.10 releases 2021-04-28 08:58:27 -04:00
Brian VaughnandGitHub 5f6c7586ed DevTools: Add Bridge protocol version backend/frontend (#21331)
Add an explicit Bridge protocol version to the frontend and backend components as well as a check during initialization to ensure that both are compatible. If not, the frontend will display either upgrade or downgrade instructions.

Note that only the `react-devtools-core` (React Native) and `react-devtools-inline` (Code Sandbox) packages implement this check. Browser extensions inject their own backend and so the check is unnecessary. (Arguably the `react-devtools-inline` check is also unlikely to be necessary _but_ has been added as an extra guard for use cases such as Replay.io.)
2021-04-27 17:26:07 -04:00
Brian VaughnandGitHub 60228a0f7e Remove unstable scheduler/tracing API (#20037) 2021-04-26 19:16:18 -04:00
Brian Vaughn 1bc9f797fe DevTools version bump 4.12.3 -> 4.12.4 2021-04-19 21:23:01 -04:00
Brian Vaughn 72120d66ef DevTools version bump 4.12.2 -> 4.12.3 2021-04-19 13:09:07 -04:00
Brian Vaughn d987e536a3 DevTools version bump 4.12.1 -> 4.12.2 2021-04-16 12:35:29 -04:00
Brian VaughnandGitHub f4d011491f Fixed bug in react-detools-inline frontend init method (#21265) 2021-04-14 13:27:21 -04:00
Brian VaughnandGitHub 0f43470e40 Add createBridge and createStore exports to react-devtools-inline (for Replay integration) (#21032) 2021-04-12 17:07:14 -04:00