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

refactor[isChildPublicInstance]: don't leak ReactNativeFiberHostComponent to Fabric implementation #27923

Merged

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Jan 10, 2024

While inspecting the build artifacts for Fabric in https://www.internalfb.com/diff/D51816108, I've noticed it has some leaking implementation details from Paper, such as ReactNativeFiberHostComponent.

The reason for it is the single implementation of isChildPublicInstance in ReactNativePublicCompat, in which we were using instanceof ReactNativeFiberHostComponent.

This new implementation removes the ReactNativeFiberHostComponent leak, but decreases the Flow coverage.

@hoxyq hoxyq requested a review from rubennorte January 10, 2024 21:17
@hoxyq hoxyq requested a review from javache January 10, 2024 21:17
@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Jan 10, 2024
@hoxyq hoxyq force-pushed the react-native/fork-is-child-public-instance branch from 1921908 to 0519a58 Compare January 10, 2024 21:18
@react-sizebot
Copy link

react-sizebot commented Jan 10, 2024

Comparing: 49439b4...5ea270a

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.min.js = 176.11 kB 176.11 kB = 54.85 kB 54.85 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.21 kB 178.21 kB = 55.49 kB 55.49 kB
facebook-www/ReactDOM-prod.classic.js = 571.71 kB 571.71 kB = 100.50 kB 100.50 kB
facebook-www/ReactDOM-prod.modern.js = 555.57 kB 555.57 kB = 97.61 kB 97.61 kB
test_utils/ReactAllWarnings.js Deleted 67.55 kB 0.00 kB Deleted 16.54 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
react-native/implementations/ReactFabric-dev.fb.js = 1,011.19 kB 1,006.41 kB = 203.18 kB 201.98 kB
react-native/implementations/ReactFabric-dev.js = 981.02 kB 976.24 kB = 198.10 kB 196.88 kB
test_utils/ReactAllWarnings.js Deleted 67.55 kB 0.00 kB Deleted 16.54 kB 0.00 kB

Generated by 🚫 dangerJS against 5ea270a

@hoxyq
Copy link
Contributor Author

hoxyq commented Jan 10, 2024

One unresolved case for me is the situation when we have an application with both renderers, and lets say that the last invoked renderer is Paper (the last opened screen is on Paper), but isChildPublicInstance is called for Fabric instances.

Is this even possible? If it is, then we should probably call this method on a specific renderer, based on the instances provided: if its Fabric instances, then call ReactFabric.isChildPublicInstance(...), same logic for ReactNativeRenderer

@hoxyq hoxyq force-pushed the react-native/fork-is-child-public-instance branch from 0519a58 to b9a6699 Compare January 11, 2024 14:03
@hoxyq hoxyq changed the title refactor: fork isChildPublicInstance implementation per renderer refactor[isChildPublicInstance]: don't leak ReactNativeFiberHostComponent to Fabric implementation Jan 11, 2024
@hoxyq
Copy link
Contributor Author

hoxyq commented Jan 11, 2024

One unresolved case for me is the situation when we have an application with both renderers, and lets say that the last invoked renderer is Paper (the last opened screen is on Paper), but isChildPublicInstance is called for Fabric instances.

Is this even possible? If it is, then we should probably call this method on a specific renderer, based on the instances provided: if its Fabric instances, then call ReactFabric.isChildPublicInstance(...), same logic for ReactNativeRenderer

Answer: this could happen for FB bundles, for which we don't have a control over which renderer to call at the certain point of time, because of factory pattern.

We also can't use public instance definition from ReactNativePrivateInterface, because it is not supplied right now.

@hoxyq hoxyq force-pushed the react-native/fork-is-child-public-instance branch from b9a6699 to 2a4a686 Compare January 11, 2024 14:10
@hoxyq hoxyq force-pushed the react-native/fork-is-child-public-instance branch from 2a4a686 to 5ea270a Compare January 11, 2024 14:11
@hoxyq hoxyq merged commit 6639ed3 into facebook:main Jan 11, 2024
36 checks passed
@hoxyq hoxyq deleted the react-native/fork-is-child-public-instance branch January 11, 2024 14:26
acdlite added a commit to vercel/next.js that referenced this pull request Jan 14, 2024
Includes a fix for useOptimistic.

React upstream changes:

- facebook/react#27936
- facebook/react#27924
- facebook/react#27930
- facebook/react#27923
- facebook/react#27922
- facebook/react#27917
- facebook/react#27916
- facebook/react#27918
- facebook/react#27919
- facebook/react#27914
- facebook/react#27911
- facebook/react#27909
- facebook/react#27907
- facebook/react#27906
- facebook/react#27905

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2096
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…nent to Fabric implementation (facebook#27923)

While inspecting the build artifacts for Fabric in
https://www.internalfb.com/diff/D51816108, I've noticed it has some
leaking implementation details from Paper, such as
`ReactNativeFiberHostComponent`.

The reason for it is the single implementation of
`isChildPublicInstance` in `ReactNativePublicCompat`, in which we were
using `instanceof ReactNativeFiberHostComponent`.

This new implementation removes the `ReactNativeFiberHostComponent`
leak, but decreases the Flow coverage.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…nent to Fabric implementation (#27923)

While inspecting the build artifacts for Fabric in
https://www.internalfb.com/diff/D51816108, I've noticed it has some
leaking implementation details from Paper, such as
`ReactNativeFiberHostComponent`.

The reason for it is the single implementation of
`isChildPublicInstance` in `ReactNativePublicCompat`, in which we were
using `instanceof ReactNativeFiberHostComponent`.

This new implementation removes the `ReactNativeFiberHostComponent`
leak, but decreases the Flow coverage.

DiffTrain build for commit 6639ed3.
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