Skip to content

Unable to register assets by name in New Runtime, only unique name #452

Description

@khaptonstall

Submission checklist

  • I have confirmed the issue is present in the latest version of RiveRuntime
  • I have searched the documentation and forums and could not find an answer
  • I have searched existing issues and this is not a duplicate

Description

When registering out of bound assets, in the Legacy Runtime, we had more granular access to and could match against the name() of the asset.

For example, say I'm using Roboto as a custom font, I could then do the following:

let viewModel = RiveViewModel(fileName: "my_rive_file") { asset, _, factory in
      if let fontAsset = asset as? RiveFontAsset {
          guard fontAsset.name() == "Roboto" else { return false }
          let decodedFont = factory.decodeFont(Data(...))
          fontAsset.font(decodedFont)
          return true
      } else {
          return false
      }
  }

In the New Runtime, we no longer have the same level of access to the underlying asset. So the above now translates into the following, where ideally I continue to register my asset by name:

let worker = try await WorkerProvider.shared.worker()

let font = try await worker.decodeFont(from: Data(...))
worker.addGlobalFontAsset(font, name: "Roboto")

This actually doesn't work, because, internally, Rive is now looking up and matching assets against uniqueName(), not name().

/rive-ios/submodules/rive-runtime/src/command_server.cpp
  Line 64: auto itr = m_fontAssets.find(asset.uniqueName());
           // Looks up "WeGoSansVariable-1234567" — NOT "Roboto

asset.uniqueName() is implemented as:

/rive-ios/submodules/rive-runtime/src/assets/
  Line 27: std::string FileAsset::uniqueName() const
  Line 30:     std::string uniqueName = name();          // "Roboto"
  Line 37:     return uniqueName + "-" + std::to_string(assetId());  // "Roboto-1234567"

For out-of-bound assets like Fonts, ideally we can continue to match against the Font name(), rather than needing to know what the uniqueName() will be, as we can only currently get that when exporting the .riv file.

Previous working version

No response

Rive Apple runtime version

6.20.5

Reproduction steps / code

No response

Upload your reproduction files / stack trace

No response

Source .riv / .rev file

No response

Screenshots / video

No response

Device

iOS Simulator

Apple OS version

iOS 25.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions