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

Why tvOS is a fork and not a module? #11

Closed
brodycj opened this issue Sep 9, 2019 · 12 comments
Closed

Why tvOS is a fork and not a module? #11

brodycj opened this issue Sep 9, 2019 · 12 comments

Comments

@brodycj
Copy link

brodycj commented Sep 9, 2019

updated:

Summary: see title which was updated several times, by multiple people, and is now a question.

Resolution: see below - agreed on my part

Original rationale:

I did not realize until after I merged brodycj/create-react-native-module#91 that tvOS was actually moved into its own package separate from the core react-native package. I then raised facebook/react-native-website#1250 to add this to the documents.

original idea now withdrawn on my part:

But I am now wondering if we could find a way to improve on a couple things.

It seems to me that this repo is a full-blown fork of react-native. I think it would be been nicer if react-native-tvos would use react-native as a dependency, and reuse as much as possible, in a similar fashion to react-native-windows, react-native-dom, and react-native-turbolinks.

I can think of the following reasons:

  • support combination with other platforms such as Windows, DOM, and possibly macOS more cleanly
  • applications and native modules can always use react-native from the standard place
  • enable applications and native modules to use react-native patch updates

(I would also like to see a similar idea applied for react-native-macos.)

more details withdrawn on my part

I think this would be a breaking change that should target an upcoming react-native release, perhaps 0.61.

Unfortunately I don't have so much time to look into this idea right now, hope I can take a look someday.

an old update now withdrawn on my part P.S. I now think that tvOS should be built from its own `tvos` subdirectory, see my response below.
@douglowder
Copy link
Collaborator

For some more context on this, see react-native-community/discussions-and-proposals#111

@brodycj brodycj changed the title out-of-tree module support out-of-tree module design Sep 9, 2019
@douglowder douglowder changed the title out-of-tree module design Why tvOS is a fork and not a module Sep 10, 2019
@douglowder
Copy link
Collaborator

The key difference between tvOS support in React Native, versus other out of tree platforms like Windows and web, is that tvOS shares almost all its native code with iOS. The tvOS-specific native code can be generally divided into these types:

  • Preprocessor directives in common Objective-C files to stub out code that won't compile on tvOS
  • Xcode project changes (or podspec additions) to exclude iOS-only features (like sliders and switches) from tvOS targets
  • tvOS-only files to implement basic functionality (RCTTVView, RCTTVEventHandler, etc.)
  • tvOS-only files to implement special features needed for some apps (RCTTVFocusGuideView, etc.)

Ideally, the core repo would have all the first three types of changes, and react-native-tvos could be a module that adds the special TV add-on features. However, the core team does not want to support tvOS there any more, and can't guarantee that the core repo will not be broken on tvOS at any given time.

(When I originally merged the tvOS changes, I added tvOS testing to the CI scripts run in open source; however, at the time, FB had a process that routinely merged changes only after running their own internal CI that didn't include tvOS.)

I could provide a tvOS module that would apply a giant patch to all the iOS files in core, but that would be a VERY large patch, probably very brittle to small changes in core, etc., etc.

So the best option I can see at the moment is running a fork, where I release versions based on specific core releases. The release notes for each tvOS version show exactly the commits applied on top of the base core release.

@brodycj

This comment has been minimized.

@YBDevelopment
Copy link

When I use this fork the app builds and compiles but when I try npm install in changes I get this error :
No matching version found for [email protected]
In most cases you or one of your dependencies are requesting
a package version that doesn't exist.

Why?

@brodycj
Copy link
Author

brodycj commented Sep 16, 2019

When I use this fork the app builds and compiles but when I try npm install in changes I get this error :
No matching version found for [email protected]
[...]

I recommend you raise a new issue with a minimal reproduction: https://stackoverflow.com/help/minimal-reproducible-example

I am not a maintainer of this module and it is not such a high priority for me to contribute any active support right now.

@douglowder
Copy link
Collaborator

I just tested this with a new app generated with react-native init.

I think the problem you are seeing is in the package.json alias dependency for react-native:

  "react-native": "npm:react-native-tvos"

This is not supported by npm install, but is supported by yarn. I recommend using yarn over npm anyway -- it's generally faster.

If you are still seeing this problem, then (as @brodybits suggested above) please create a new issue with a minimal set of repro steps.

@brodycj
Copy link
Author

brodycj commented Sep 17, 2019

From discussion in #14, I would now conclude that this project is really a fork to support one or more TV operating systems, as opposed to a truly separate "out-of-tree" module.

This would be very similar to the way that Expo has its own expo/react-native fork, which it uses to release the various Expo SDK versions.

Now downvoting and hiding my own idea in #11 (comment) as resolved.

@keshavkaul
Copy link
Collaborator

Since this is a fork of react-native, then the release schedule for this repo will practically not be the same as the parent repo, so in a scenario where I will need to upgrade ios/android mobile apps to latest react-native versions, I will have to wait for tvOS to make a release. Right?

@douglowder
Copy link
Collaborator

@keshavkaul you are correct, you will have to wait until this repo supports the latest RN core version. That would likely be a problem even if this were an add-on module instead of a fork. There have been quite a few changes in recent versions of RN core that broke tvOS....

@keshavkaul
Copy link
Collaborator

Thanks! I'm now leaning towards having a monorepo project setup either with lerna or yarn workspaces. We plan on supporting mobile, tv, web, firetv, Xbox, so having each platform be a separate package with their own dependencies but re using common code seems ideally feasible. Any thoughts you'd like to share about advantages or disadvantages of monorepos will greatly help me out. Thanks again for the TV repo! I will surely be investing time to contribute here.

@pavjacko
Copy link
Contributor

@dlowder-salesforce great effort trying to keep react-native tvos alive 🥇

I wondered same when I tried to integrate this into
https://github.com/pavjacko/renative

I managed to get some of initial issues out of the way however there are some outstanding issues to tackle (which forced me to stick with RN + some overrides at least for now):

  • ios-only dependencies
    biggest problem I faced was with some of the fundamentals still cross-wired with ios implementations

This made it very difficult to use it alongside standard react-native as renative has to support multiplatform monorepos

  • lack of native plugins
    even in renative I had to "hack" quite a few libraries to even compile for tvos and I managed to get few of them working but it's still a bit of a way. easied integration to existing RN project would make this more viable for plugin developers

  • bundler naming collisions
    this happens if you try to run tvos and standard RN under same project as there are duplicate classes present in node_modules

  • versioning, keeping up to date with RN
    I wonder what's the strategy of keeping this in sync with latest RN releases. as at the time of testing it was 1 major release (0.61 in RN) causing causing compatibility issues

  • focus issues
    even with this repo I has some issues with focusable elements. I managed to fix those but it was small enough to be able to retro fix directly in RN
    focus guides are helpful but it still not enough for more complex focus scenarios from the experience but with bit of tweaking definitely possible

@keshavkaul multi-platform RN monorepo is definitely possible
renative itself started as lerna project https://github.com/pavjacko/renative/tree/master/packages

I think if above obstacles would be solved it could definitely be viable alternative to current RN situation on tvos platform

@dlowder-salesforce I think most of the fundamentals are in RN and with good API (RN is moving towards smaller core anyway) tvos support could be achieved with smaller and more focused implementation as native extension and maybe with some overrides (at least that's how I managed to get it all somehow working)

Just thinking out loud

keep up the great work 👍

@douglowder
Copy link
Collaborator

@pavjacko thanks for the excellent commentary -- sorry I didn't respond sooner, I was offline due to medical issues for a couple of weeks.

bundler naming collisions

In a monorepo, I would either use this package, or the RN core package, but not both. This repo is intended to work for iOS, tvOS, and Android, and just add tvOS fixes to what is already in core.

versioning, keeping up to date with RN

This is discussed in detail in #32

lack of native plugins

Third party support for RN tvOS is a problem. I've managed to get a number of them working. Most of the time it's just adding tvOS to the podspec, but sometimes actual code changes are required.

focus issues

I'd be interested to hear about the issues you encountered and your fixes. Did you submit fixes to RN core directly?

tvos support could be achieved with smaller and more focused implementation

Not sure what you mean by this, but if you have ideas that would lead to easier tvOS maintenance, I'd love to hear them :)

@brodycj brodycj changed the title Why tvOS is a fork and not a module Why tvOS is a fork and not a module? Apr 7, 2020
douglowder pushed a commit that referenced this issue Nov 7, 2024
…(#46702)

Summary:
Pull Request resolved: facebook/react-native#46702

In facebook/react-native#44188, we've started combining multiple transactions in a single transaction, to meet React's atomicity requirements, while also dealing with the constraints of Android's Fabric implementation.

This revealed a bug where in some scenarios (especially when using transitions), a node may be deleted and created during the same transaction. The current implementation of FabricMountingManager assumes it can safely reorder some operations, which it does to optimize the size of IntBufferBatch mount items. This is however incorrect and unsafe when multiple transactions are merged.

**Example:**

Differentiator output:

```
# Transaction 1
Remove #100 from #11
Delete #100

# Transaction 2
Create #100
Insert #100 into #11
```
FabricMountingManager output
```
Remove #100 from #11
Insert #100 into #11
Delete #100
```

Note that the create action is also skipped, because we only update `allocatedViewTags` after processing all mutations, leading FabricMountingManager to assume creation is not required.

This leads to an invalid state in SurfaceMountingManager, which will be surfaced as a crash in `getViewState` on the next mutation that interacts with these views.

Changelog: [Android][Fixed] Fix crash in getViewState when using suspense fallbacks.

Reviewed By: sammy-SC

Differential Revision: D63148523

fbshipit-source-id: 07ae26b2f7b7eba1b9784041dd3059b0956c035e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants