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

[ios][expotools] Fixes for versioned TurboModules #9862

Merged
merged 4 commits into from
Aug 25, 2020

Conversation

sjchmiela
Copy link
Contributor

Why

After versioning, TurboModules integration started to make more harm than good.

How

  • moved creating of the JSCExecutorFactory, which should be versioned, to versioned realm (otherwise we try to pass an unversioned code into a versioned bridge) (huge thanks to C++ senpai @wkozyra95 for assistance)
    • to achieve this I unfortunately had to modify react-native to
      1. expect void * from jsExecutorFactoryForBridge:, otherwise we can't pass versioned factory through unversioned and back into versioned
      2. do not detect whether delegate is an instance of RCTCxxBridgeDelegate by protocol, but by the actual method used. This is because delegate for all bridges is always EXReactAppManager which is not versioned.
    • another change is that EXVersionManager now holds strongly one instance of the JSCExecutorFactory instead of just creating it on every call. I think this shouldn't break anything, as on each bridge reload we create a new instance of EXVersionManager and there shouldn't be more calls to jsExecutorFactoryForBridge: apart from when setting the bridge up, but I think it's a note-worthy mention here.
  • then I bumped into the XX is not a registered callable module error which led me to update expotools's pattern for adding EX_REMOVE_VERSION to MessageQueue.

Test Plan

I have verified that these fixes work on a separate branch.

Copy link
Contributor

@wkozyra95 wkozyra95 left a comment

Choose a reason for hiding this comment

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

Originally I misunderstand a bit what you wanted to do, change I suggested will still require a modifications in react-native but at least the lifecycle of object will be preserved.

In this PR I see pointer converted to void*, but I don't see anywhere that would restore it, am I missing sth?

ios/Exponent/Versioned/Core/EXVersionManager.mm Outdated Show resolved Hide resolved
ios/Exponent/Versioned/Core/EXVersionManager.mm Outdated Show resolved Hide resolved
@wkozyra95
Copy link
Contributor

I updated my suggestion after looking into react-native changes

ios/Exponent/Versioned/Core/EXVersionManager.mm Outdated Show resolved Hide resolved
ios/Exponent/Versioned/Core/EXVersionManager.mm Outdated Show resolved Hide resolved
@sjchmiela sjchmiela force-pushed the @sjchmiela/turbomodules-fixes branch from 3e837ad to acb85e4 Compare August 25, 2020 09:07
@sjchmiela sjchmiela merged commit b42dcb4 into master Aug 25, 2020
@sjchmiela sjchmiela deleted the @sjchmiela/turbomodules-fixes branch August 25, 2020 09:09
bbarthec pushed a commit that referenced this pull request Aug 25, 2020
# Why

After versioning, TurboModules integration started to make more harm than good.

# How

- moved creating of the `JSCExecutorFactory`, which should be versioned, to versioned realm (otherwise we try to pass an unversioned code into a versioned bridge) (huge thanks to C++ senpai @wkozyra95 for assistance)
  - to achieve this I unfortunately had to modify `react-native` to
    1. expect `void *` from `jsExecutorFactoryForBridge:`, otherwise we can't pass versioned factory through unversioned and back into versioned
    2. do not detect whether delegate is an instance of `RCTCxxBridgeDelegate` by protocol, but by the actual method used. This is because delegate for all bridges is always `EXReactAppManager` which is not versioned.
  - another change is that `EXVersionManager` now **holds strongly** one instance of the `JSCExecutorFactory` instead of just creating it on every call. I think this shouldn't break anything, as on each bridge reload we create a new instance of `EXVersionManager` and there shouldn't be more calls to `jsExecutorFactoryForBridge:` apart from when setting the bridge up, but I think it's a note-worthy mention here.
- then I bumped into the `XX is not a registered callable module` error which led me to update `expotools`'s pattern for adding `EX_REMOVE_VERSION` to `MessageQueue`.

# Test Plan

I have verified that these fixes work on a separate branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants