Commit dec621d
committed
fix(hooks): reset during render on source change; main-hop legacy Android getViewModelInstance
Two fixes from the second cold review:
- The loading reset moved from the effect into render (adjust-state-
during-render): the effect-time reset let React commit one frame
pairing the new source with the previous instance at isLoading:
false — a mismatch consumer guards can't catch (e.g. <RiveView
file={fileB} dataBind={instanceA}/> reaching native) — and then
disposed that instance while still committed. New unit test captures
committed frames on a source flip and fails on the old behavior
(26 mismatched frames).
- Legacy Android's HybridRiveView.getViewModelInstance() read
controller.stateMachines on the JS thread while the main thread
mutates it during startup (issue #297 race class; iOS already hops
via MainThread.run). Now reads under
runBlocking(Dispatchers.Main.immediate). No deterministic test is
possible for the race; the ref-source e2e tests exercise this path
on the android-legacy CI job.1 parent d3b17e3 commit dec621d
3 files changed
Lines changed: 76 additions & 5 deletions
File tree
- android/src/legacy/java/com/margelo/nitro/rive
- src/hooks
- __tests__
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
119 | 126 | | |
120 | 127 | | |
121 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
536 | 585 | | |
537 | 586 | | |
538 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
334 | 353 | | |
335 | 354 | | |
336 | 355 | | |
| |||
342 | 361 | | |
343 | 362 | | |
344 | 363 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | 364 | | |
350 | 365 | | |
351 | 366 | | |
| |||
0 commit comments