Commit b0f823c
Keep subview-clipping bookkeeping in sync when addViewAt reparents a view
Summary:
When the Fabric mounting layer inserts a view that unexpectedly still has a parent, `SurfaceMountingManager.addViewAt` takes evasive action and removes the view from its current parent before re-adding it to the new one. That recovery used a raw `ViewGroup.removeView`, which detaches the view from the Android view hierarchy but does not update a clipping-enabled parent's internal child bookkeeping (the `allChildren` array maintained while `removeClippedSubviews` is set).
As a result, the old parent kept a stale reference to a view that had just been reparented elsewhere. A later clipping pass on that parent then asserted the child was still parented to it and threw an `IllegalStateException`, crashing the app.
Route the evasive removal through the current parent's `ViewManager` (when its view state is known) so the clipping-aware removal path runs and the `allChildren` bookkeeping stays consistent. Behavior is unchanged for non-clipping parents, which still fall back to the raw `removeView`.
Changelog:
[Android][Fixed] - Fix rare crash in views using `removeClippedSubviews` when a child is reparented during mounting
Differential Revision: D1100596991 parent 3fcde34 commit b0f823c
1 file changed
Lines changed: 28 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
398 | 425 | | |
399 | 426 | | |
400 | 427 | | |
| |||
0 commit comments