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

fix: use public instance in Fiber renderer and expose it from getInspectorDataForViewAtPoint #31068

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Sep 26, 2024

React DevTools no longer operates with just Fibers, it now builds its own Shadow Tree, which represents the tree on the Host (Fabric on Native, DOM on Web).

We have to keep track of public instances for a select-to-inspect feature. We've recently changed this logic in #30831, and looks like we've been incorrectly getting a public instance for Fabric case.

Not only this, turns out that all getInspectorData... APIs are returning Fibers, and not public instances. I have to expose it, so that React DevTools can correctly identify the element, which was selected.

Changes for React Native are in D63421463

Copy link

vercel bot commented Sep 26, 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 8:54am

@react-sizebot
Copy link

Comparing: 778e1ed...0180849

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 507.20 kB 507.20 kB = 90.80 kB 90.80 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 512.13 kB 512.13 kB = 91.52 kB 91.52 kB
facebook-www/ReactDOM-prod.classic.js = 603.73 kB 603.73 kB = 106.83 kB 106.84 kB
facebook-www/ReactDOM-prod.modern.js = 579.95 kB 579.95 kB = 102.92 kB 102.92 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
react-native/shims/ReactNativeTypes.js +0.48% 8.73 kB 8.78 kB +0.34% 2.34 kB 2.35 kB

Generated by 🚫 dangerJS against 2c30d0a

Comment on lines +775 to +776
typeof instance.canonical.publicInstance === 'object' &&
instance.canonical.publicInstance !== null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can this be a non-object? In Legacy Fabric, for example?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not AFAIK. And canonical is only available in Fabric.

if (typeof instance === 'object' && instance !== null) {
if (typeof instance.canonical === 'object' && instance.canonical !== null) {
if (
typeof instance.canonical.publicInstance === 'object' &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: you can reduce nesting here combining the conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've decided to do nesting instead, because combining will produce a very long line, looks a bit uglier :(

Copy link
Contributor

@rubennorte rubennorte left a comment

Choose a reason for hiding this comment

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

LGTM

@hoxyq hoxyq merged commit d66fa02 into facebook:main Sep 26, 2024
184 checks passed
@hoxyq hoxyq deleted the react-native/expose-public-instance-from-inspector-data-for-view-at-point branch September 26, 2024 09:17
github-actions bot pushed a commit that referenced this pull request Sep 26, 2024
…ectorDataForViewAtPoint (#31068)

React DevTools no longer operates with just Fibers, it now builds its
own Shadow Tree, which represents the tree on the Host (Fabric on
Native, DOM on Web).

We have to keep track of public instances for a select-to-inspect
feature. We've recently changed this logic in
#30831, and looks like we've been
incorrectly getting a public instance for Fabric case.

Not only this, turns out that all `getInspectorData...` APIs are
returning Fibers, and not public instances. I have to expose it, so that
React DevTools can correctly identify the element, which was selected.

Changes for React Native are in
[D63421463](https://www.internalfb.com/diff/D63421463)

DiffTrain build for commit d66fa02.
hoxyq added a commit to hoxyq/react-native that referenced this pull request Sep 26, 2024
Summary:
# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Differential Revision: D63421463
hoxyq added a commit to hoxyq/react-native that referenced this pull request Sep 26, 2024
Summary:
Pull Request resolved: facebook#46664

# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Differential Revision: D63421463
hoxyq added a commit to hoxyq/react-native that referenced this pull request Sep 26, 2024
Summary:
Pull Request resolved: facebook#46664

# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Differential Revision: D63421463
hoxyq added a commit to hoxyq/react-native that referenced this pull request Sep 26, 2024
Summary:
Pull Request resolved: facebook#46664

# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Reviewed By: huntie

Differential Revision: D63421463
hoxyq added a commit to hoxyq/react-native that referenced this pull request Sep 27, 2024
Summary:
Pull Request resolved: facebook#46664

# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Reviewed By: huntie

Differential Revision: D63421463
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Sep 27, 2024
Summary:
Pull Request resolved: #46664

# Changelog: [Internal]

Please see facebook/react#31068.

Synced changes for React Native - D63453667.

Reviewed By: huntie

Differential Revision: D63421463

fbshipit-source-id: e455711206598a06f7cdce4150e79c3548843b99
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
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants