Commit 58df7da
fix(android): prevent crash from double release during navigation (#46)
The Rive Android SDK's RiveViewLifecycleObserver releases dependencies
on fragment lifecycle onDestroy. During React Navigation screen transitions,
fragments are destroyed before views are actually disposed, causing
release() to be called when refs are already at 0.
Crash:
java.lang.IllegalArgumentException: Failed requirement.
at app.rive.runtime.kotlin.controllers.RiveFileController.release()
Fix ports the proven willDispose pattern from rive-react-native:
- ReactNativeRiveViewLifecycleObserver: overrides onDestroy to skip
auto-release, adds explicit dispose() method
- ReactNativeRiveAnimationView: custom RiveAnimationView that uses
our lifecycle observer
- RiveReactNativeView: adds willDispose flag, only cleans up in
onDetachedFromWindow when flag is set
- RiveViewManager: extends HybridRiveViewManager to call dispose()
in onDropViewInstance (when React Native removes the view)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 29de2ca commit 58df7da
4 files changed
Lines changed: 60 additions & 6 deletions
File tree
- android/src/main/java/com
- margelo/nitro/rive
- rive
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
43 | 74 | | |
44 | 75 | | |
45 | | - | |
| 76 | + | |
46 | 77 | | |
47 | 78 | | |
48 | 79 | | |
| 80 | + | |
49 | 81 | | |
50 | 82 | | |
51 | | - | |
| 83 | + | |
52 | 84 | | |
53 | 85 | | |
54 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
55 | 99 | | |
56 | 100 | | |
57 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments