Files
react-native/ReactCommon/react/renderer/core
Samuel Susla 270060e1d9 Pass weak pointers to background executor lambda
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
2021-02-22 17:02:19 -08:00
..
2021-01-04 04:12:30 -08:00
2021-01-10 19:46:40 -08:00
2021-01-04 04:12:30 -08:00
2021-01-04 04:12:30 -08:00
2021-01-07 13:42:24 -08:00
2021-01-07 13:42:24 -08:00