Support for custom JavaScript runtimes for the new architecture in Android #48942
+26
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
In the old architecture, we have the ability to easily change the JavaScript runtime on Android using the overridden
getJavaScriptExecutorFactory
function in theReactNativeHost
abstract class. This creates a new instance of the factory and an executor with assigned runtime. However, in the new architecture, engine selection occurs in theDefaultReactHost
object and depends on theisHermesEnabled
property of theReactNativeHost
class. This logic is limited to engine selection between Hermes and JSC and lacks the ability to easily override it (as is the case with iOS code).This PR includes a modification of this mechanism so that the function responsible for selecting the Runtime is in the
DefaultReactNativeHost
object – this will allow it to be written from within the project'sMainApplication
class, e.g:Exactly as was the case with the old architecture and function:
This is particularly important when using custom JS engines other than Hermes or JSC in a project, such as the V8 (https://github.com/Kudo/react-native-v8), or smaller engines tailored to selected devices or solutions.
Changelog:
[ANDROID] [CHANGED] - Moving the Javascript Runtime selection to the DefaultReactNativeHost object to allow selection of custom JS runtimes
Test Plan:
All tests were successfully completed.