Commit e869f82
Fix LayoutAnimation crash from mutation sort ordering
Summary:
`LayoutAnimationDriver::animationMutationsForFrame` was sorting animation-frame Update mutations together with structural mutations (Remove/Insert/Delete) from completed animations. Animation-frame Updates reference views by their pre-structural-change parentTag. When `std::stable_sort` reordered these Updates after Remove/Insert pairs that reparented a view, `StubViewTree::mutate` hit a parentTag mismatch assertion (`react_native_assert(oldStubView->parentTag == mutation.parentTag)`) and crashed with SIGABRT.
The fix records the boundary between animation-frame Updates and final structural mutations, then only sorts the structural portion. This preserves the invariant that animation-frame Updates execute before any structural changes.
Additionally, the mutation comparator in `utils.h` was missing an explicit `Update < Insert` ordering rule, which could cause nondeterministic sort results between Update and Insert mutations of different types. This is now handled.
The test fixture is converted to `TEST_F` with a `LayoutAnimationTest` class that enables the `fixDifferentiatorParentTagForUnflattenCase` feature flag, ensuring consistent parentTag assignment across platforms.
Changelog: [Internal]
Differential Revision: D1026968751 parent c20a58a commit e869f82
4 files changed
Lines changed: 60 additions & 14 deletions
File tree
- packages/react-native/ReactCommon/react/renderer/animations
- tests
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
102 | | - | |
103 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
104 | 109 | | |
105 | | - | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| |||
Lines changed: 40 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
| |||
326 | 340 | | |
327 | 341 | | |
328 | 342 | | |
329 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
330 | 355 | | |
331 | 356 | | |
332 | 357 | | |
| |||
341 | 366 | | |
342 | 367 | | |
343 | 368 | | |
344 | | - | |
| 369 | + | |
345 | 370 | | |
346 | 371 | | |
347 | 372 | | |
| |||
356 | 381 | | |
357 | 382 | | |
358 | 383 | | |
359 | | - | |
| 384 | + | |
360 | 385 | | |
361 | 386 | | |
362 | 387 | | |
| |||
371 | 396 | | |
372 | 397 | | |
373 | 398 | | |
374 | | - | |
| 399 | + | |
375 | 400 | | |
376 | 401 | | |
377 | 402 | | |
| |||
386 | 411 | | |
387 | 412 | | |
388 | 413 | | |
389 | | - | |
| 414 | + | |
390 | 415 | | |
391 | 416 | | |
392 | 417 | | |
| |||
401 | 426 | | |
402 | 427 | | |
403 | 428 | | |
404 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
405 | 432 | | |
406 | 433 | | |
407 | 434 | | |
| |||
414 | 441 | | |
415 | 442 | | |
416 | 443 | | |
417 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
418 | 447 | | |
419 | 448 | | |
420 | 449 | | |
| |||
454 | 483 | | |
455 | 484 | | |
456 | 485 | | |
457 | | - | |
| 486 | + | |
458 | 487 | | |
459 | 488 | | |
460 | 489 | | |
| |||
472 | 501 | | |
473 | 502 | | |
474 | 503 | | |
475 | | - | |
| 504 | + | |
476 | 505 | | |
477 | 506 | | |
478 | 507 | | |
| |||
490 | 519 | | |
491 | 520 | | |
492 | 521 | | |
493 | | - | |
| 522 | + | |
494 | 523 | | |
495 | 524 | | |
496 | 525 | | |
| |||
511 | 540 | | |
512 | 541 | | |
513 | 542 | | |
514 | | - | |
| 543 | + | |
515 | 544 | | |
516 | 545 | | |
517 | 546 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
0 commit comments