GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: allow custom impl of backend realod-to-profile support check by EdmondChuiHW · Pull Request #31048 · react/react

Conversation

@EdmondChuiHW

@EdmondChuiHW EdmondChuiHW commented Sep 24, 2024

Copy link
Copy Markdown
Contributor

Summary

In preparation to support reload-to-profile in Fusebox (#31021), we need a way to check capability of different backends, e.g. web vs React Native.

How did you test this change?

  • Default, e.g. existing web impl = no-op
  • Custom impl: is called

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@EdmondChuiHW
EdmondChuiHW requested a review from hoxyq September 24, 2024 16:35
@vercel

vercel Bot commented Sep 24, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 10:36am
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added the CLA Signed label Sep 24, 2024
@vercel
vercel Bot deployed to Preview September 24, 2024 16:38
View deployment
hoxyq
hoxyq reviewed Sep 24, 2024
View reviewed changes
Comment thread packages/react-devtools-shared/src/bridge.js Outdated
inspectedElement: [InspectedElementPayload],
isBackendStorageAPISupported: [boolean],
isSynchronousXHRSupported: [boolean],
isReloadAndProfileSupported: [boolean],

@hoxyq hoxyq Sep 24, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be backendSupportsReloadAndProfile or isReloadAndProfileSupportedByBackend?

The final version is up to you, I just want it to explicitly mention that this is about backend.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

EdmondChuiHW reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread packages/react-devtools-core/src/backend.js Outdated
}

const agent = new Agent(bridge);
bridge.send('isReloadAndProfileSupported', isReloadAndProfileSupported());

@hoxyq hoxyq Sep 24, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move it somewhere. Can this actually be an argument on initBackend?

Notice that you don't have any changes related to the browser extension, this is because it has its own logic for backend initialization:
https://github.com/facebook/react/blob/fc4a33eaa9c935ac860ab6043b95d55540068571/packages/react-devtools-extensions/src/contentScripts/backendManager.js#L99-L161

Then, inside initBackend, we could do something like:

if (isReloadAndProfileSupported()) {
  agent.onReloadAndProfileSupportedByHost();
}

and inside Agent this method would just send this event:

this._bridge.send('isReloadAndProfileSupported', true);

and the only remaining thing is hardcoding true for initBackend call in the extension code, which I've referenced above

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

EdmondChuiHW reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@hoxyq hoxyq Sep 24, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow us to reuse as much as possible, and reduce the fragmentation: instead of having custom logic, like here in react-devtools-core/src/backend.js, we would pass an argument to initBackend, which is from react-devtools-shared

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

EdmondChuiHW reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@EdmondChuiHW EdmondChuiHW Sep 24, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Much cleaner to have this logic back into Agent/initBackend. Updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@EdmondChuiHW
EdmondChuiHW force-pushed the custom-reload2profile-check branch 2 times, most recently from 32a04cc to 19ad6d1 Compare September 24, 2024 23:03
@EdmondChuiHW
EdmondChuiHW requested a review from hoxyq September 24, 2024 23:06
@vercel
vercel Bot deployed to Preview September 24, 2024 23:06
View deployment
hoxyq
hoxyq reviewed Sep 25, 2024
View reviewed changes
Comment thread packages/react-devtools-shared/src/backend/index.js Outdated
});

const getIsReloadAndProfileSupported =
hook.settings?.getIsReloadAndProfileSupported ??

@hoxyq hoxyq Sep 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't do anything, because you don't store it on the Hook object, and you don't need to.

Can you add boolean optional parameter to initBackend here?
https://github.com/facebook/react/blob/a15bbe14751287cb7ac124ff88f694d0883f3ac6/packages/react-devtools-shared/src/backend/index.js#L16-L20

Then, anywhere where you are calling initBackend: browser extension content script, react-devtools-core, react-devtools-inline, you will provide this argument.

For browser extension it will be true by default, for react-devtools-inline it will be false (we don't support it), for react-devtools-core this will be the return of the function isReloadAndProfileSupported, which is passed from the Host (React Native in our case)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

EdmondChuiHW reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@EdmondChuiHW
EdmondChuiHW force-pushed the custom-reload2profile-check branch 2 times, most recently from 3f6d608 to 9a7cec7 Compare September 25, 2024 14:00
@vercel
vercel Bot deployed to Preview September 25, 2024 14:04
View deployment
hoxyq
hoxyq reviewed Sep 25, 2024
View reviewed changes
Comment thread packages/react-devtools-shared/src/backend/index.js Outdated
hook: DevToolsHook,
agent: Agent,
global: Object,
getIsReloadAndProfileSupported: () => boolean = defaultGetIsReloadAndProfileSupported,

@hoxyq hoxyq Sep 25, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be boolean with a default value false? And then wrappers around it are going to pass just a boolean value, and react-devtools-core is going to pass getIsReloadAndProfileSupported().

With a current implementation, the extension is going to use defaultGetIsReloadAndProfileSupported, but actually it should just receive a static true value.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@EdmondChuiHW EdmondChuiHW Sep 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the extension still need to check the local/session storage capabilities, e.g. incognito mode?

Edit: I'm inclined to keep this PR focused on just the refactoring, i.e. keeping existing things working the way it has been, even if it's suboptimal/obsolete. We can follow up and remove the checks in a separate PR as needed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@EdmondChuiHW
EdmondChuiHW requested a review from hoxyq September 25, 2024 16:25
@EdmondChuiHW EdmondChuiHW mentioned this pull request Sep 26, 2024
Add: reload to profile for Fusebox #31021
Merged
@EdmondChuiHW
refactor: allow custom impl of backend realod-to-profile support check
a474aa8
@EdmondChuiHW
EdmondChuiHW force-pushed the custom-reload2profile-check branch from 9a7cec7 to a474aa8 Compare September 26, 2024 10:31
@vercel
vercel Bot deployed to Preview September 26, 2024 10:36
View deployment
hoxyq
hoxyq approved these changes Sep 26, 2024
View reviewed changes
@EdmondChuiHW
EdmondChuiHW merged commit f8024b0 into react:main Sep 26, 2024
@EdmondChuiHW
EdmondChuiHW deleted the custom-reload2profile-check branch September 26, 2024 11:39
EdmondChuiHW added a commit that referenced this pull request Sep 26, 2024
@EdmondChuiHW
Add: reload to profile for Fusebox (#31021)
204a551
## Summary

Add reload to profile for Fusebox 

Stacked on #31048. See
6be1977

## How did you test this change?

Test E2E in [D63233256](https://www.internalfb.com/diff/D63233256)
This was referenced Sep 26, 2024
Upgrade React from 778e1ed2-20240926 to 204a551e-20240926 vercel/next.js#70525
Closed
Upgrade React from 778e1ed2-20240926 to 67fee58b-20240926 vercel/next.js#70539
Closed
Upgrade React from 778e1ed2-20240926 to 3edc000d-20240926 vercel/next.js#70560
Merged
gnoff added a commit to vercel/next.js that referenced this pull request Sep 27, 2024
@vercel-release-bot @gnoff
Upgrade React from 778e1ed2-20240926 to 3edc000d-20240926 (#70560)
af8af5e
**breaking change for canary users: Bumps peer dependency of React from
`19.0.0-rc-778e1ed2-20240926` to `19.0.0-rc-3edc000d-20240926`**

[diff
react/react@778e1ed2...3edc000d](react/react@778e1ed...3edc000)

<details>
<summary>React upstream changes</summary>

- react/react#31078
- react/react#31083
- react/react#31079
- react/react#31080
- react/react#31076
- react/react#31021
- react/react#31069
- react/react#31074
- react/react#31073
- react/react#31047
- react/react#31046
- react/react#31045
- react/react#31072
- react/react#30980
- react/react#30463
- react/react#30694
- react/react#31039
- react/react#31048
- react/react#31068

</details>

---------

Co-authored-by: Josh Story <[email protected]>
@hoxyq hoxyq mentioned this pull request Oct 15, 2024
React DevTools 6.0.0 -> 6.0.1 #31263
Merged
hoxyq added a commit that referenced this pull request Oct 15, 2024
@hoxyq
React DevTools 6.0.0 -> 6.0.1 (#31263)
c7c68ef
Changes in this release:

* Fix React Compiler badging ([poteto](https://github.com/poteto) in
[#31196](#31196))
* fix[react-devtools]: fixed timeline profiler tests
([hoxyq](https://github.com/hoxyq) in
[#31261](#31261))
* fix[react-devtools]: record timeline data only when supported
([hoxyq](https://github.com/hoxyq) in
[#31154](#31154))
* refactor[react-devtools]: flatten reload and profile config
([hoxyq](https://github.com/hoxyq) in
[#31132](#31132))
* fix[react-devtools]: remove all listeners when Agent is shutdown
([hoxyq](https://github.com/hoxyq) in
[#31151](#31151))
* fix[react-devtools]: removed redundant startProfiling call
([hoxyq](https://github.com/hoxyq) in
[#31131](#31131))
* refactor[react-devtools/fiber/renderer]: optimize durations resolution
([hoxyq](https://github.com/hoxyq) in
[#31118](#31118))
* fix[react-devtools]: update profiling status before receiving response
from backend ([hoxyq](https://github.com/hoxyq) in
[#31117](#31117))
* fix[react-devtools]: wrap key string in preformatted text html element
([hoxyq](https://github.com/hoxyq) in
[#31153](#31153))
* chore[react-devtools]: drop legacy context tests
([hoxyq](https://github.com/hoxyq) in
[#31059](#31059))
* chore[react-devtools]: add legacy mode error message to the ignore
list for tests ([hoxyq](https://github.com/hoxyq) in
[#31060](#31060))
* fix[react-devtools]: request hook initialization inside http server
response ([hoxyq](https://github.com/hoxyq) in
[#31102](#31102))
* [Flight] Serialize Server Components Props in DEV
([sebmarkbage](https://github.com/sebmarkbage) in
[#31105](#31105))
* Add: reload to profile for Fusebox
([EdmondChuiHW](https://github.com/EdmondChuiHW) in
[#31021](#31021))
* refactor: allow custom impl of backend realod-to-profile support check
([EdmondChuiHW](https://github.com/EdmondChuiHW) in
[#31048](#31048))
* fix: use public instance in Fiber renderer and expose it from
getInspectorDataForViewAtPoint ([hoxyq](https://github.com/hoxyq) in
[#31068](#31068))
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@EdmondChuiHW
refactor: allow custom impl of backend realod-to-profile support check (
6ef98cf
react#31048)

<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

In preparation to support reload-to-profile in Fusebox (react#31021), we need
a way to check capability of different backends, e.g. web vs React
Native.

## How did you test this change?

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->

* Default, e.g. existing web impl = no-op
* Custom impl: is called
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@EdmondChuiHW
Add: reload to profile for Fusebox (react#31021)
4ef1e33
## Summary

Add reload to profile for Fusebox 

Stacked on react#31048. See
react@6be1977

## How did you test this change?

Test E2E in [D63233256](https://www.internalfb.com/diff/D63233256)
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
React DevTools 6.0.0 -> 6.0.1 (react#31263)
f27d7a0
Changes in this release:

* Fix React Compiler badging ([poteto](https://github.com/poteto) in
[react#31196](react#31196))
* fix[react-devtools]: fixed timeline profiler tests
([hoxyq](https://github.com/hoxyq) in
[react#31261](react#31261))
* fix[react-devtools]: record timeline data only when supported
([hoxyq](https://github.com/hoxyq) in
[react#31154](react#31154))
* refactor[react-devtools]: flatten reload and profile config
([hoxyq](https://github.com/hoxyq) in
[react#31132](react#31132))
* fix[react-devtools]: remove all listeners when Agent is shutdown
([hoxyq](https://github.com/hoxyq) in
[react#31151](react#31151))
* fix[react-devtools]: removed redundant startProfiling call
([hoxyq](https://github.com/hoxyq) in
[react#31131](react#31131))
* refactor[react-devtools/fiber/renderer]: optimize durations resolution
([hoxyq](https://github.com/hoxyq) in
[react#31118](react#31118))
* fix[react-devtools]: update profiling status before receiving response
from backend ([hoxyq](https://github.com/hoxyq) in
[react#31117](react#31117))
* fix[react-devtools]: wrap key string in preformatted text html element
([hoxyq](https://github.com/hoxyq) in
[react#31153](react#31153))
* chore[react-devtools]: drop legacy context tests
([hoxyq](https://github.com/hoxyq) in
[react#31059](react#31059))
* chore[react-devtools]: add legacy mode error message to the ignore
list for tests ([hoxyq](https://github.com/hoxyq) in
[react#31060](react#31060))
* fix[react-devtools]: request hook initialization inside http server
response ([hoxyq](https://github.com/hoxyq) in
[react#31102](react#31102))
* [Flight] Serialize Server Components Props in DEV
([sebmarkbage](https://github.com/sebmarkbage) in
[react#31105](react#31105))
* Add: reload to profile for Fusebox
([EdmondChuiHW](https://github.com/EdmondChuiHW) in
[react#31021](react#31021))
* refactor: allow custom impl of backend realod-to-profile support check
([EdmondChuiHW](https://github.com/EdmondChuiHW) in
[react#31048](react#31048))
* fix: use public instance in Fiber renderer and expose it from
getInspectorDataForViewAtPoint ([hoxyq](https://github.com/hoxyq) in
[react#31068](react#31068))
@hoxyq hoxyq mentioned this pull request Oct 30, 2026
DevTools: React Native: Support reload-and-profile #16471
Closed

This branch was successfully deployed

1 active deployment
Preview — a474aa80 Deployed Sep 26, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hoxyq hoxyq hoxyq approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@EdmondChuiHW @hoxyq @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.