Commit 9c8f57c
authored
fix: make play/pause control the experimental render loop (iOS + Android) (#285)
## Problem
On the experimental backend, `play()`/`pause()`/`reset()` were no-ops —
animations couldn't be paused/resumed and `autoPlay={false}` was
ignored.
- **iOS**: only mutated a private `isPaused` flag never forwarded to
`RiveUIView`.
- **Android**: empty bodies; the render loop advanced unconditionally
and `autoPlay` was never consumed.
Additionally, `useRiveTrigger` never fired on Android experimental —
three separate issues:
1. `awaitViewReady()` resolved at end of `configure()`, before the
TextureView surface existed. Triggers fired before the surface was up
were lost.
2. `getTriggerFlow` has `replay=0` (no initial value on subscription);
`drop=1` was silently eating the first real trigger.
3. The listener coroutine was launched with `DEFAULT` start, so it was
merely queued on `Dispatchers.Default` and could miss a trigger fired
before it reached `collect()`.
Also, `dataBind={{ byName }}` on Android always bound from
`vmNames.first()` (first VM in file) instead of the artboard's default
ViewModel.
## Fix
- **iOS** (`ios/new/RiveReactNativeView.swift`): forward `isPaused` to
`RiveUIView` in play/pause/playIfNeeded, pass it into
`RiveUIView(rive:isPaused:)`, set it from `autoPlay`.
- **Android** (`android/src/new/.../RiveReactNativeView.kt`): gate
`advanceStateMachine` on a `paused` flag toggled by play/pause, honor
`autoPlay`. Signal `awaitViewReady()` on first rendered frame (not end
of configure).
- **Android triggers**: use `drop=0` for trigger flow (no initial value
to skip); launch listener coroutine with `CoroutineStart.UNDISPATCHED`.
- **Android byName**: use `ViewModelSource.DefaultForArtboard(art)`
instead of `Named(vmNames.first())`, matching iOS and the Auto path.
- **reset()**: deprecated. Neither experimental backend has a reset
primitive — marked `@deprecated` in the spec, experimental impl logs an
error and does nothing.
## Verification
- `autoplay.harness.tsx`: pause freezes `ypos`, play resumes it,
`autoPlay={false}` holds. Green on both platforms.
- `use-rive-trigger.harness.tsx`: both stable and unstable-callback
tests now pass on Android.
- `viewmodel-instance-lookup.harness.tsx`: byName regression test
verifies `artboard2 + byName("vmi1") → _id="vm2.vmi1.id"` (not vm1).
- CI: legacy iOS `pod install` step clears `Podfile.lock` to avoid
external `fast_float` checksum rejection.1 parent b8bca90 commit 9c8f57c
11 files changed
Lines changed: 261 additions & 86 deletions
File tree
- .github/workflows
- android/src
- main/java/com/margelo/nitro/rive
- new/java/com
- margelo/nitro/rive
- rive
- example
- __tests__
- android/.kotlin/errors
- ios/new
- src/specs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| |||
387 | 392 | | |
388 | 393 | | |
389 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
390 | 399 | | |
391 | 400 | | |
392 | 401 | | |
| |||
413 | 422 | | |
414 | 423 | | |
415 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
416 | 430 | | |
417 | 431 | | |
418 | 432 | | |
| |||
582 | 596 | | |
583 | 597 | | |
584 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
585 | 603 | | |
586 | 604 | | |
587 | 605 | | |
| |||
606 | 624 | | |
607 | 625 | | |
608 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
609 | 632 | | |
610 | 633 | | |
611 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
132 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
133 | 139 | | |
134 | 140 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
211 | | - | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
| |||
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| |||
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
340 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
341 | 344 | | |
342 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
343 | 348 | | |
344 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
345 | 353 | | |
346 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
347 | 357 | | |
348 | 358 | | |
349 | 359 | | |
| |||
0 commit comments