SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

Do not strongly own State from Java (#36699)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36699

Changelog: [internal]

This fixes a crash introduced in D43692171 where `jsi::Pointer` outlives `jsi::Runtime` in which it was created. This leads to a crash.
The diff changed ownership model, retaining `TextLayoutManager` strongly from `ParagraphState`.

To resolve this, in this diff we change how `StateWrapperImpl` owns state, moving from shared_ptr to weak_ptr. We have tried to do it previously in D26815275 but it had to be reverted because it broke end to end tests. I made sure the tests are fine. However it is the right ownership model. Java objects should not strongly hold onto anything in ShadowTree. If ShadowTree is destroyed, Java calls should noop, not keep objects in memory and have them handle the case when runtime was destroyed.

jest_e2e[run_all_tests]

Reviewed By: cipolleschi

Differential Revision: D44472121

fbshipit-source-id: 83b79329440ac1211902ea9511c0dde9a77ab9e9
S
Samuel Susla committed
a9e7da12af3b3fcf20ac786f3b3540dad01b56bf
Parent: fec5658
Committed by Facebook GitHub Bot <[email protected]> on 3/29/2023, 4:11:47 PM