Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: reload to profile for Fusebox #31021

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

EdmondChuiHW
Copy link
Contributor

@EdmondChuiHW EdmondChuiHW commented Sep 22, 2024

Summary

Add reload to profile for Fusebox

Stacked on #31048. See 6be1977

How did you test this change?

Test E2E in D63233256

Copy link

vercel bot commented Sep 22, 2024

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 3:43pm

Comment on lines 292 to 295
if (this._isProfiling === isProfiling) {
return;
}

Copy link
Contributor Author

@EdmondChuiHW EdmondChuiHW Sep 22, 2024

Choose a reason for hiding this comment

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

There are existing crashes reported on web:

#30661
#28838

Adding support for Fusebox in the PR encountered similar crashes.

These lines fix it for Fusebox; it could be the fix for web as well.

That's because onProfilingStatus is called repeatedly on some occasions, e.g. multiple calls to getProfilingStatus

EdmondChuiHW added a commit that referenced this pull request Sep 23, 2024
<!--
  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

Profiling fails sometimes because `onProfilingStatus` is called
repeatedly on some occasions, e.g. multiple calls to
`getProfilingStatus`.

Subsequent calls should be a no-op if the profiling status hasn't
changed.

Reported via #30661 #28838.

> [!TIP]
> Hide whitespace changes on this PR

<img width="328" alt="screenshot showing the UI controls for hiding
whitespace changes on GitHub"
src="https://github.com/user-attachments/assets/036385cf-2610-4e69-a717-17c05d7ef047">


## 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.
-->

Tested as part of Fusebox implementation of reload-to-profile.

#31021
@EdmondChuiHW EdmondChuiHW force-pushed the reload2profile-fusebox branch 2 times, most recently from 6be1977 to d8da2b9 Compare September 26, 2024 03:16
@EdmondChuiHW EdmondChuiHW marked this pull request as ready for review September 26, 2024 03:16
EdmondChuiHW added a commit that referenced this pull request Sep 26, 2024
#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 (#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
@EdmondChuiHW EdmondChuiHW marked this pull request as draft September 26, 2024 11:43
@EdmondChuiHW EdmondChuiHW marked this pull request as ready for review September 26, 2024 12:46
packages/react-devtools-shared/src/attachRenderer.js Outdated Show resolved Hide resolved
@@ -60,6 +63,7 @@ export function initialize(
maybeSettingsOrSettingsPromise?:
| DevToolsHookSettings
| Promise<DevToolsHookSettings>,
reloadAndProfileConfig: ReloadAndProfileConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this is unused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is passed in from setUpReactDevTools.js https://www.internalfb.com/diff/D63233256?permalink=3800761013473689

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but this is unused in this function.

You are passing this in connectToDevTools and in connectWithCustomMessagingProtocol, and you are using it there

Copy link
Contributor Author

@EdmondChuiHW EdmondChuiHW Sep 26, 2024

Choose a reason for hiding this comment

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

We're using it in all three places. initialize needs the initial (heh) boolean values to pass onto renderer, and the connect* functions need the full *ConfigPersistence to read & write the flags

Edit: LOL I see what you mean now 🤦‍♂️ Thanks for the permalink.

export function initialize(
maybeSettingsOrSettingsPromise?:
| DevToolsHookSettings
| Promise<DevToolsHookSettings>,
reloadAndProfileConfig: ReloadAndProfileConfig,
) {
installHook(window, maybeSettingsOrSettingsPromise);
}

It got messed up during rebase. Fixed now

@EdmondChuiHW EdmondChuiHW merged commit 204a551 into facebook:main Sep 26, 2024
158 of 159 checks passed
@EdmondChuiHW EdmondChuiHW deleted the reload2profile-fusebox branch September 26, 2024 15:39
gnoff added a commit to vercel/next.js that referenced this pull request Sep 27, 2024
abhi12299 pushed a commit to abhi12299/next.js that referenced this pull request Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants