-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR is a pinnacle of Reanimated's version detection grand scheme. Since there are numerous errors stemming from having parts of Reanimated used from different version we decided to enforce runtime checks for those parts - to make the troubleshooting process easier. Adding: - C++ checks JavaScript version - C++ checks Java version - Java checks C++ version Requires #4915 ## Test plan 1. C++ checks JavaScript version: Trigger failed resolution: ```diff // src/reanimated2/NativeReanimated/NativeReanimated.ts - global._REANIMATED_VERSION_JS = jsVersion; ``` Trigger wrong version: ```diff // src/reanimated2/NativeReanimated/NativeReanimated.ts - global._REANIMATED_VERSION_JS = jsVersion; + global._REANIMATED_VERSION_JS = 'wrong-version'; ``` 2. C++ checks Java version: Trigger failed resolution: ```diff // android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java public String getReanimatedJavaVersion() { - return BuildConfig.REANIMATED_VERSION_JAVA; + throw new RuntimeException("forced fail"); } ``` Trigger wrong version: ```diff // android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java public String getReanimatedJavaVersion() { - return BuildConfig.REANIMATED_VERSION_JAVA; + return new String("wrong-version"); } ``` 3. Java checks C++ version: Trigger failed resolution: ```diff // android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java protected void setCppVersion(String version) { - cppVersion = version; + // NOOP } ``` Trigger wrong version: ```diff // android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java protected void setCppVersion(String version) { - cppVersion = version; + cppVersion = new String("wrong-version"); } ```
- Loading branch information
Showing
15 changed files
with
236 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
#include <string> | ||
|
||
using namespace facebook; | ||
|
||
namespace reanimated { | ||
|
||
jsi::String getReanimatedVersionString(jsi::Runtime &rt); | ||
std::string getReanimatedCppVersion(); | ||
|
||
}; | ||
#ifdef DEBUG | ||
bool matchVersion(const std::string &, const std::string &); | ||
void checkJSVersion(jsi::Runtime &); | ||
#endif // DEBUG | ||
|
||
}; // namespace reanimated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.