Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call assert in
SingleInstanceChecker
only in example apps (#4316)
Currently, Reanimated crashes on some configurations due to an assert in `SingleInstanceChecker` which was meant to help us detect retain cycles and thus memory leaks in the library at an early stage but actually causes lots of troubles in client apps. This PR changes the behavior of `SingleInstanceChecker` so that it always prints the warning to the console but calls the failing `assert` only in Reanimated example apps (i.e. Example or FabricExample). This PR wraps the failing assert inside a preprocessor conditional based on the flags passed from `build.gradle` via `CMakeLists.txt` (Android) or `RNReanimated.podspec` (iOS). Additionally, it introduces `__android_log_print` instead of `std::cerr` on Android so that the warning is also visible in logcat. Android: <img width="1493" alt="android" src="https://user-images.githubusercontent.com/20516055/229063204-36af61a7-1ace-4a64-bf43-4cb1caceb44f.png"> iOS: <img width="898" alt="ios" src="https://user-images.githubusercontent.com/20516055/229063251-d1b66d79-58ff-4077-a88c-f8d368d74377.png"> 1. Check if `IS_REANIMATED_EXAMPLE_APP` preprocessor definition is properly injected on both platforms: - Android: change implementation of `isReanimatedExampleApp` in build.gradle to always return `true` - iOS: assign `true` to `result[:is_reanimated_example_app]` in `reanimated_utils.rb` - add the following snippet in `SingleInstanceChecker.h`: ```cpp ``` 2. Check if the example apps crash on reload: - modify the condition in `SingleInstanceChecker.h` so that it always fails - the app should crash on launch 3. Check if the client apps don't crash on reload but show a warning: - modify the condition in `SingleInstanceChecker.h` so that it always fails - build the package locally - create a new RN app and install Reanimated - the app shouldn't crash on launch - there should be a warning in Android Logcat / iOS app output console
- Loading branch information