Skip to content

feat: experimental iOS API support (getEnums via SPM)#134

Draft
mfazekas wants to merge 5 commits intomainfrom
feat/rive-ios-experimental
Draft

feat: experimental iOS API support (getEnums via SPM)#134
mfazekas wants to merge 5 commits intomainfrom
feat/rive-ios-experimental

Conversation

@mfazekas
Copy link
Collaborator

@mfazekas mfazekas commented Jan 23, 2026

Summary

  • Converts entire Rive API from async (Promise-based) to synchronous
  • Adds optional SPM integration for RiveRuntime 6.15.0 (experimental API)
  • Experimental iOS backend uses blockingAsync helper to bridge async rive-ios API to sync interface
  • Legacy iOS and Android backends simply remove Promise.async {} wrappers (underlying SDK is already sync)
  • Simplifies React hooks (useViewModelInstance, useRiveProperty) — no more useState + useEffect for async loading
  • Properties use value getter/setter instead of getValue()/setValue()

Usage

USE_RIVE_SPM=1 pod install

Without the flag, the legacy (CocoaPods) backend is used.

Known Issues (experimental iOS runtime)

Use-after-free crash on navigation back

After interacting with a view (e.g. pressing "update label" in MenuList), pressing back causes a crash in rive::CommandQueue::processMessages:

Thread 1: EXC_BAD_ACCESS (code=1, address=0xbeadde99d448)

#0 rive::CommandQueue::processMessages()
#1 CA::Display::DisplayLinkItem::dispatch_()

This is a use-after-free in the Rive C++ engine — the CADisplayLink fires after the Worker/ViewModelInstance have been deallocated. The command queue needs to be drained or the display link invalidated before teardown. This is upstream in rive-ios, not fixable on our side.

See docs/commandqueue-crash-on-teardown.md for full repro.

valueStream throws missingData on empty nested property

Setting a nested ViewModel string property to "" causes valueStream to throw missingData, killing the listener permanently. Empty string is a valid value and should not be treated as missing data. We work around this by restarting the stream on error.

See docs/valuestream-missingdata-on-empty-string.md for full repro.

@mfazekas mfazekas force-pushed the feat/rive-ios-experimental branch from 491c96b to 95816cf Compare January 23, 2026 11:15
Add RiveFile.getEnums() to retrieve enum definitions from Rive files.
iOS uses the new experimental API (RiveRuntime 6.15.0 via SPM),
Android uses existing File.enums property.
Conditional compilation ensures it builds with both SPM and CocoaPods.
Set USE_RIVE_SPM=1 with pod install to enable.
@mfazekas mfazekas force-pushed the feat/rive-ios-experimental branch from 95816cf to 4fe9e12 Compare January 23, 2026 11:23
mfazekas and others added 3 commits January 26, 2026 08:13
Adds new experimental iOS backend (ios/new/) using RiveRuntime's Worker + CommandQueue
architecture. Converts RiveFile, ViewModel, and property APIs to async to support the
experimental iOS API's thread-safe command queue. Updates hooks and example app accordingly.
- Convert all Promise-based APIs to sync (properties, viewModel methods, file queries)
- Add blockingAsync main-thread precondition guard
- Fix Color property Int32 overflow crash in experimental backend
- Add CommandQueue teardown crash documentation

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
override fun getEnums(): Array<RiveEnumDefinition> {
val file = riveFile ?: return emptyArray()
return try {
file.enums.map { enum ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:chain-method-continuation reported by reviewdog 🐶
Expected newline before '.'

- Wrap valueStream iteration in retry loop for all property types
- Restore TestComponentOverlay removed by mistake
- Fix React Compiler catch variable bug in TestsPage
- Add missingData upstream issue doc

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant