Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix initialisation of NodesManager (#1030)
## Description Previously, `NodesManager` registered (passing `this`) as an event listener before ending initialization in c-tor. `NodesManager` is created by `ReanimatedModule` (when calling `getNodesManager()` for the first time) on [UI thread](https://github.com/software-mansion/react-native-reanimated/blob/9af276693d136b712259fe9dd0126aee6c78bd4b/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java#L77-L80). When `onEventDispatch()` is called on non-UI thread it calls `startUpdatingOnAnimationFrame()`, which in turn uses `mChoreographerCallback`. `mChoreographerCallback` is initialised **after** listener is registered which causes NPE in React Choreographer's `postFrameCallback()` method after trying adding callback to the queue. Fixes #604. References: https://www.ibm.com/developerworks/java/library/j-jtp0618/index.html#2 https://stackoverflow.com/questions/25281301/what-exactly-are-the-dangers-of-passing-this-from-a-java-constructor
- Loading branch information