Memory consumption for card game: 52 artboards in one file vs. separate files?
Hi Rive Team,
I'm building a Flutter card game and need clarification on memory management and best practices for handling 52 playing card animations.
My Situation
- 52 playing cards (Ace through King, 4 suits)
- Each card has unique animation of reveal
- Typical game state: 10-20 cards visible on screen simultaneously
- Each card animation is approximately 250KB when saved as individual .riv file
My Questions
1. File Structure - What's recommended?
Should I use:
- Option A: One `cards.riv` file with 52 artboards (one per card)
- Option B: 52 separate `.riv` files (one per card)
2. Memory Consumption - How does it actually work?
When I load a single `cards.riv` file containing 52 artboards:
final riveFile = await RiveFile.asset('assets/cards.riv'); // File is 250KBQuestion 2a: Are all 52 artboard definitions loaded into memory immediately, or only loaded on demand when I call `.artboardByName()`?
Question 2b: When I create arboard instances for 20 visible cards:
final card1 = riveFile.artboardByName('ace_spades')!.instance();
final card2 = riveFile.artboardByName('2_hearts')!.instance();
// ... 18 more cardsWhat is the memory footprint?
- Is it: `250KB (file) + (20 × instance_overhead)` ?
- Or does each artboard instance duplicates 250KB of data?
- What is the approximate overhead per artboard instance?
- Do unused artboards (not yet instanced) consume additional memory beyond the initial file load?
3. Performance - Loading & Rendering
Question 3a: Does having unused artboards in a file impact performance of the active artboards? (e.g., does having 52 artboards slow down 20 active ones?)
Question 3b: Is there a recommended maximum number of artboards per file?
Question 3c: For 52 separate files vs. 1 combined file:
- Which has better runtime performance if only one artboard is used per instance or there is no effective difference if file is cached?