Commit 0fabe26
Make image prefetch JNI batching thread-safe (#54861)
Summary:
Pull Request resolved: #54861
The JNI batching for image prefetching was leading to crashes due to the following thread-safety issue in the ImageFetcher implementation:
* Image requests are made from the ImageShadowNode layout call, these can happen from any thread.
* Image request flushing happens from `FabricUIManagerBinding::schedulerShouldRenderTransactions()`, meaning on mount
* A commit could happen while a mount is running. Meaning the image fetcher `items_` read/write has to be synchronized to avoid data corruption.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D88970631
fbshipit-source-id: ef25e3b78e6c23a786c8e225eb3abf0bc04213a51 parent 41380f3 commit 0fabe26
2 files changed
Lines changed: 18 additions & 10 deletions
File tree
- packages/react-native/ReactCommon/react/renderer/imagemanager/platform/android/react/renderer/imagemanager
Lines changed: 16 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
44 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | | - | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
61 | | - | |
62 | | - | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
0 commit comments