mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
270060e1d9
Summary: Changelog: [internal] ### Why does the crash happen? The crash can happen if runtime is destroyed before background executor lambda is run. Destroying a shadow node after runtime leads to a crash through the chain of ownerships. Chain of ownership: `ShadowNode -> ShadowNodeFamily -> EventEmitter -> EventTarget -> Pointer` Pointer tries to call `invalidate` method on raw pointer to the runtime which is gone. https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactCommon/jsi/jsi/jsi.h?commit=2ee3ae0c6a64&lines=335-339 To work around this, weak pointers are passed to lambda. This way the lambda is less likely to be the last owner of shadow nodes. Possibility of race still exists but it less likely to happen. ## Other solution Alternatively, we could make sure native Runnable queue in Java is emptied as part of tear down process. We can even implement both solutions as they are semantically correct. Reviewed By: shergin Differential Revision: D26582554 fbshipit-source-id: b1b8a92237902bc4c40376176f575caa24a41a05