Commit 182dc37
authored
Resolve sync UI updates concurency issue on iOS (software-mansion#4403)
## Summary
This PR tries to address the problem with assert that we make in
`REANodesManager.mm` when receiving mounting block from the React's UI
Manager.
The issue was due to a fact that we only hold a single reference for
mounting block as well as the timed-out flag, while under certain
conditions, the `performOperations` may re-enter before these values are
cleaned up correctly. This didn't happen before software-mansion#4239 because the lock
would guarantee that `performIOperation` is never called again before
the block scheduled on UIManagerQueue is finished. However in software-mansion#4239 we
changed this behavior to stop potential ANR issues due to locking and
this caused this new issue to surface.
The change we are making here is that we create a new instance of
observer that is specific to a given `performOperation` call. This way
every call to `performOperation` shares an instance of observer with
UIManagerQueue bloc, which keeps ref to mounting block and timeout flag,
hence it is never possible for read/writes of these refs to interfere
between subsequent `performOperation` runs.
We are now also moving the assert to the new place – to the observer
dealloc. We always expect the mounting block to be executed (and cleaned
up) and hence if the observer is deallocated with the mounting block
set, we treat this as an error.
## Test plan
We couldn't manage to reproduce this issue but it was tested courtesy of
@gavrix who could reliably reproduce the assert failure on one of the
apps he works on.1 parent 4a2838b commit 182dc37
1 file changed
Lines changed: 67 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
96 | 157 | | |
97 | 158 | | |
98 | 159 | | |
99 | 160 | | |
100 | 161 | | |
101 | 162 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 163 | | |
106 | 164 | | |
107 | 165 | | |
| |||
129 | 187 | | |
130 | 188 | | |
131 | 189 | | |
132 | | - | |
133 | 190 | | |
134 | 191 | | |
135 | 192 | | |
| |||
245 | 302 | | |
246 | 303 | | |
247 | 304 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | 305 | | |
262 | 306 | | |
263 | 307 | | |
| |||
272 | 316 | | |
273 | 317 | | |
274 | 318 | | |
275 | | - | |
276 | | - | |
| 319 | + | |
277 | 320 | | |
278 | 321 | | |
279 | 322 | | |
| |||
282 | 325 | | |
283 | 326 | | |
284 | 327 | | |
285 | | - | |
| 328 | + | |
286 | 329 | | |
287 | 330 | | |
288 | 331 | | |
289 | 332 | | |
290 | 333 | | |
291 | 334 | | |
292 | 335 | | |
293 | | - | |
294 | | - | |
| 336 | + | |
| 337 | + | |
295 | 338 | | |
296 | 339 | | |
297 | 340 | | |
| |||
302 | 345 | | |
303 | 346 | | |
304 | 347 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
| 348 | + | |
316 | 349 | | |
317 | 350 | | |
318 | 351 | | |
| |||
0 commit comments